Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Scalar context changes bareword value?

by Fletch (Chancellor)
on Apr 22, 2004 at 13:30 UTC ( #347347=note: print w/replies, xml ) Need Help??

in reply to Scalar context changes bareword value?
in thread Stumped when passing barewords

The bareword is the same in scalar context, however the array @_ in scalar context is another matter. @_ itself hasn't changed, but when you pass it to sub2 it's put in scalar context ("*" is behaving similarly to "$" in this case).

Replies are listed 'Best First'.
Re: Scalar context changes bareword value?
by crenz (Priest) on Apr 22, 2004 at 13:35 UTC
    Thanks for the explanation! I can just pass $_[0] in this situation, which should make it work. However, if there would be multiple parameters and I wanted to pass @_ as a whole, there'd be a problem :(.

      Well, not a problem but you'd have to call it as sub2( $_[0]  => @_[1..$#_] ). Then again, you play with prototypes you're going to get burned. Or was that matches . . .

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2016-10-21 21:51 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (291 votes). Check out past polls.