Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: The default hash - accident, coincidence or conspiracy?

by kaif (Friar)
on Jun 21, 2005 at 01:12 UTC ( #468530=note: print w/replies, xml ) Need Help??

in reply to The default hash - accident, coincidence or conspiracy?

I discovered the %_ variable when I tried to write

sub foo { # takes a hash argument my %_ = @_; }

and discovered that that doesn't work. Later, I thought "of course" (because of typeglobs!) and used local %_ instead. Although the presence of "the same" %_ regardless of package may be a problem, as mentioned above, maintaining this should be no more difficult than similar code using $_ and @_.

Replies are listed 'Best First'.
Re^2: The default hash - accident, coincidence or conspiracy?
by SimonClinch (Deacon) on Jun 22, 2005 at 14:07 UTC
    Original post: Funny, I tried that out too at some time ... then I realised I just had to convert the array to hash via a list form
    Foo( trouble => brewing ); sub Foo{ my %param = (@_); print "trouble is $param{ trouble }\n"; }

    Update: Oops I missed the quick reference to typeglobs, otherwise I would have replied: What the post I am replying to might have said is that the typeglob *_ has been predefined in the global symbol table, not just the $_ and @_ individually - I could not find a documentation reference to %_ nor *_"

      No, you've completely missed kaif's point. You cannot   my %_   ever. It is illegal. By your response, your solution was to use a different variable name, not "convert the array to hash via a list form".
        Illegal? It is treated as such in the sense that it was globally reserved and thereby prevented, but until it is documented as such, it can't be called 'illegal'.

        One world, one people

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://468530]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-05-26 20:02 GMT
Find Nodes?
    Voting Booth?