まず$sizeの初期化なのだけど、昔はそうやっていたのですが、「use warnings」を使い始めたら、
$size = 5 if (not defined $size or $size < 1);ってのは無駄が多い。
$size = 5 if $size < 1;で充分。
% cat a.pl
#!/usr/bin/perl
use strict;
use warnings;
my $size;
testest($size);
sub testest {
my ($size) = @_;
print "hello\n" if $size < 1;
}
% ./a.pl
Use of uninitialized value in numeric lt (<) at ./a.pl line 8.
hello
my $var;
($var = <<HERE_TARGET) =~ s/^\s+//gm;
your text
goes here
HERE_TARGET
でも、最後の「閉じ用文字列(?)」はインデントできないのがなあ。
my $here = qq:to/以上/;
一行
二行
以上
