Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^2: Common Perl Idioms

by revdiablo (Prior)
on Jul 23, 2004 at 21:19 UTC ( #376999=note: print w/replies, xml ) Need Help??

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 :->

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://376999]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2023-03-28 17:58 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (68 votes). Check out past polls.