Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

RE: RE: RE: Passing named parameters

by Adam (Vicar)
on May 09, 2000 at 21:05 UTC ( [id://10778]=note: print w/replies, xml ) Need Help??


in reply to RE: RE: Passing named parameters
in thread Passing named parameters

Which is why -beer isn't a bareword. But the => is equivalent to a , (comma) thus ending the bareword, er string. So then
    -beer, none
will result in none being a bareword. At least, that's how I understand it.

Replies are listed 'Best First'.
RE: RE: RE: RE: Passing named parameters
by perlmonkey (Hermit) on May 09, 2000 at 23:57 UTC
    You are correct of course.
    non strict code:
    &a(-beer=>none); sub a { print join("=>",@_); }
    This will product the correct results of "-beer=>none" as long as you are not using 'strict' or -w, but of course nobody does that ... right? So to be proper:
    use strict; &a(-beer=>'none'); sub a { print join("=>",@_); }
    and this will product the same results, with no warnings.

      Sorry to reply 4 years later. The - has nothing to do with the string or bareword. The => says qoute whats on my left and pretend i'm a comma. so a(-beer=>none) is the same as a("beer", none); Perhaps this is what the original author meant but I wasn't sure and thought i might clarify a bit.


      ___________
      Eric Hodges
        I assume that "is the same as a('beer', none)" is a typo, ... and that you meant "is the same as a('-beer', 'none')"

        And since we are clarifying ... the '-' is part of the key (or the first argument, depending on how you look at it).
        bash$ perl -w -Mstrict -MData::Dumper -e \ "print Dumper( { -name => 'foo', -value => 'bar' } );"
        Results:
        $VAR1 = { '-name' => 'foo', '-value' => 'bar' };

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (7)
As of 2024-04-19 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found