http://qs321.pair.com?node_id=376999


in reply to Re: Common Perl Idioms
in thread Common Perl Idioms

Your slurp:

@files = { local(@ARGV, $/) = @filenames; <> }; # missing 'do'

Should actually be:

@files = do { local(@ARGV, $/) = @filenames; <> };

And your index hash:

@foo{ @foo } = 0 .. @foo; # off-by-one error

Should be:

@foo{ @foo } = 0 .. $#foo;

Replies are listed 'Best First'.
Re^3: Common Perl Idioms
by Anonymous Monk on Jul 23, 2004 at 23:21 UTC

    You are right about the slurp, a typo on my part.

    But the indexing will work. The extra number (int @foo) will just be ignored because there won't be a corresponding lvalue.

    Ted :->