Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: what is bad about this?

by kutsu (Priest)
on Feb 06, 2006 at 21:42 UTC ( #528344=note: print w/ replies, xml ) Need Help??

in reply to what is bad about this?

Because your program won't run (actually it will run but will also fill up your logs with a lot of unnessary warnings) under warnings and strict (if you want to know why it's a good idea to have them on Use strict warnings and diagnostics or die). But as to why it's a bad idea in general check out this quote from diagnostics:

Scalar value @a[1] better written as $a[1] at -e line 1 (#1) (W syntax) You've used an array slice (indicated by @) to select a single element of an array. Generally it's better to ask for a scalar value (indicated by $). The difference is that $foo[&bar] always behaves like a scalar, both when assigning to it and when evaluating its argument, while @foo[1] behaves like a list when you assign to it, and provides a list context to its subscript, which can do weird things if you're expecting only one subscript.
On the other hand, if you were actually hoping to treat the array element as a list, you need to look into how references work, because Perl will not magically convert between scalars and lists for you. See perlref.

Comment on Re: what is bad about this?

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2015-11-30 11:03 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls