「すぐわかるPerl」2.2 Printで遊んでみよう
Microsoft Virtial PC2007にfedora core6をいれて、そこでperlを動かしてます。
こちらの方がviとかを使える(学べる)分、良いかもしれないですね。
printで出力するとき、文字列のみであれば()は不要となる。
[sironekotoro@localhost perl-study]$ cat flashy
#! /usr/bin/perl
# flashy -- 派手な挨拶のプログラム
print "************************************************\n";
print "*** hello! Welcome! to the perl World!(^-^) ****\n";
print "************************************************\n";[sironekotoro@localhost perl-study]$ perl flashy
************************************************
*** hello! Welcome! to the perl World!(^-^) ****
************************************************
一個のprint命令で出力してみた場合。冗長だけど、結果は同じ。
[sironekotoro@localhost perl-study]$ cat flashy-long
#! /usr/bin/perl
# flashy -- 派手な挨拶のプログラム
print "************************************************\n*** hello! Welcome! to the perl World!(^-^) ****\n************************************************\n";[sironekotoro@localhost perl-study]$ perl flashy-long
************************************************
*** hello! Welcome! to the perl World!(^-^) ****
************************************************
改行は\nという特殊文字によって行われる。
\tはタブの挿入。
[sironekotoro@localhost perl-study]$ perl
print "L\n\tL\n\t\tL\n\t\t\tL\n";
L
L
L
L
print文で分けても同じ表現になる。
[sironekotoro@localhost perl-study]$ perl
print "L\n";
print "\tL\n";
print "\t\tL\n";
print "\t\t\tL\n";
L
L
L
L
| 固定リンク
「Perl」カテゴリの記事
- 「すぐわかるPerl」 8.10 ディレクトリのリカーシブ処理(その2)(2009.02.24)
- 「すぐわかるPerl」 8.10 ディレクトリのリカーシブ処理(その1)(2009.02.23)
- 「すぐわかるPerl」 7.6 マッチした文字列と、その前後の文字列を扱う変数(2008.06.17)
- 「すぐわかるPerl」 8.9 コマンドの入出力に入出力を切り替える(2008.11.12)
- 「すぐわかるPerl」 8.8 標準入出力以外のファイルの制御(2008.10.08)









コメント