Perl Gem, Filehandle Quoting

From Bilbo
Jump to: navigation, search


This Perl code actually does not emit any warnings or errors!

use strict;
use warnings;

On further investigation, this code ...


use strict;
use warnings;

my @q = </table asdf>;

print "Length:  ", scalar(@q), "\n";
print "$_\n" foreach @q;

... generates this output ...

Length:  2

Go figure.

While the notation <table> would emit an error (because the filehandle named "table" isn't open and thus can't be read from), if the junk inside the brackets is not a single bareword, Perl treats it more like qw-quoting, where it separates the inside on spaces and returns it as a list of strings. There Are Too Many Ways To Do It.