【perl】ヒアドキュメント
ファイル名 capter1_5.pl
#! usr/bin/perl use strict; use warnings; my $task = 'study perl'; my $time = '10:00am-11:00am'; my $html = <<"plans"; <html> <head> <title>today's my schedule</title> </head> <body> <h1>$task</h1> <p>available labor time is $time.</p> <p>If you have conflicted schedules, please rethink your plan.</p> </body> </html> plans print $html;
以上のプログラムを実行した後、.html形式で保存するとブラウザでも確認できる(localhost)。
コマンド例↓
D:\usr\xampp\htdocs\study>perl capter1_5.pl > capter1_5.html
このようにすると、.plを実行して標準出力を.htmlで保存できる。
capter1_5.plと比較すると、次のcapter1_6.plは<<'plan'となっている(シングルクォート)。個の場合、変数は展開されずに表示される。
ファイル名 capter1_6.pl
#! usr/bin/perl use strict; use warnings; my $task = 'study perl'; my $time = '10:00am-11:00am'; my $html = <<'plans'; <html> <head> <title>today's my schedule</title> </head> <body> <h1>$task</h1> <p>available labor time is $time.</p> <p>If you have conflicted schedules, please rethink your plan.</p> </body> </html> plans print $html;