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

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.

Replies are listed 'Best First'.
Re: RE: RE: RE: RE: Passing named parameters
by eric256 (Parson) on Mar 25, 2004 at 16:59 UTC

    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' };