Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: what is bad about this?

by kutsu (Priest)
on Feb 06, 2006 at 21:42 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found