http://www.perlmonks.org?node_id=991202


in reply to Re: RFC: Idiom for named read-write arguments (aliases) instead of using $_[0] etc
in thread RFC: Idiom for named read-write arguments (aliases) instead of using $_[0] etc

well using parts of it doesn't make it an idiom or pattern.

can't see any \( ) in juerd's code and the other examples look like obfuscation contest for me not like an advice for an idiom.

Cheers Rolf

  • Comment on Re^2: RFC: Idiom for named read-write arguments (aliases) instead of using $_[0] etc
  • Download Code

Replies are listed 'Best First'.
Re^3: RFC: Idiom for named read-write arguments (aliases) instead of using $_[0] etc
by BrowserUk (Patriarch) on Sep 02, 2012 at 16:29 UTC

    Looking again, I see you are right. Whilst related, they are not the same usage.

    By way of penance:

    sub swap{ our($a,$b); local( *a, *b ) = \( @_ ); ($a, $b ) = ( $b, $a ) } my( $x, $y ) = ( 1, 'fred' ); swap( $x, $y ); print "$x, $y";; fred, 1 print swap( 1, 'fred' );; fred 1

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    RIP Neil Armstrong

      good point, since $a and $b are magical globals you can even avoid the our-decalaration (in this case)

      Cheers Rolf

        Didn't think of that, but I have to wonder if $a & $b are really that much better than $_[0] & $_[1] ?

        Okay for swap(), I guess.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

        RIP Neil Armstrong