- or download this
while (<FH>) {
chomp $_;
$a[$i]=$_;
$i++;
}
- or download this
@a = <FH>; # diamond operator in "list" (or array) context
# will read all input records into array elements
chomp @a; # chomp can work on a list
- or download this
while (<FH>) {
chomp; # $_ is the default arg to chomp;
...
push @a, $_; # add a new element at end of @a
}
- or download this
perl -e '@a=qw/one two three four/; print @a,$/'
perl -e '@a=qw/one two three four/; print "@a$/"'
perl -e '@a=qw/one two three four/; print join(" ", map { "foo=$_" }
+@a), $/'