user-pic

pumpingcode

  • Commented on I hate unpacking sub calls with shift
    Newcomers need to understand that sub call arguments are passed in an array. And to appreciate the power of arrays, a programmer needs to understand how shift, unshift, pop, push etc are array operators. I agree that placing a shift...
Subscribe to feed Recent Actions from pumpingcode

  • Tom Molesworth commented on I hate unpacking sub calls with shift

    $! is common enough that it shouldn't need comments, though?

    If the argument is that people learning perl won't understand them, I'd disagree:

    open my $fh, '

    tends to be covered very early in most tutorials, and is also described in perldoc perlopentut. To some extent the same applies to $/, reading in paragraph mode or in fixed chunks is something that you encounter very early.…

  • Olivier Mengué (dolmen) commented on I hate unpacking sub calls with shift

    Note also that @_ is alias to arguments given to the sub which means that it gives you not only read access to the argument, but also write access if it is a variable.

    my $a = 2;
    say $a;
    
    

    sub change_arg_0
    {
    $_[0] = 1;
    }

    change_arg_0($a);
    say $a;

Subscribe to feed Responses to Comments from pumpingcode

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl with a graphic design donated by Six Apart, Ltd.