Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://528344]
help
Chatterbox?
[marto]: ah, so this is payback :P
[LanX]: problem with booking venues is that you only know the number of participants a week in advance. ..
[marto]: I guess most cities have areas similar to this, I tend not to mind personally, but would not go out of my way to head down that way
[marto]: it'll probably be fine.
[marto]: LanX: I appreciate that, it's honestly a difficult thing, a fine balance
[marto]: I'm sure it'll be fun :)
[marto]: of course I can take you to some of the best/worst bars in Glasgow ;)
[LanX]: is Glasgow that city where catholics and protestants fight in bars? ; )
[marto]: not really, but pick your side, we'll visit some real dumps

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2017-12-14 15:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (397 votes). Check out past polls.

    Notices?