On Tue, Feb 07, 2012 at 08:20:06AM -0500, Shawn H Corey wrote:
> Inside a sub, shift without an argument will shift @_. Outside, it
> will shift @ARGV. It is always best to explicitly state the array:
> 
> sub header {
>         my $month = shift @_;
>         my $year  = shift @_;

Even better can be just assigning your arguments array to a list
of lvalues:

use strict;
use warnings;

sub header
{
    my ($month, $year) = @_;

    # ...
}

header(qw/January 2012/);

This way is very clean and simple. It shows a clear relationship
between the position and the argument and allows you add new
arguments with less code. Use shift if you actually want to
remove elements from the beginning of the array.

Regards,


-- 
Brandon McCaig <bamcc...@gmail.com> <bamcc...@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

Attachment: signature.asc
Description: Digital signature

Reply via email to