Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-07-29 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls