> Personally I find context one of the most fascinating aspects of Perl 
> (Maybe someone should do a presentation!) and I must admit I've been 
> guilty of referring to things as being in "Array Context".  Does anyone 
> disagree with these postings or have any additional knowledge to share?

The only case that should not be used is caught by use warnings.  Maybe I just 
think in "Perl context" nowadays...

perl -Mwarnings -e ' $a =      (5,6,7); print "$a\n"' #scalar assignment of 
list  => 7 #never use this "feature"...
perl -Mwarnings -e '($a)=      (5,6,7); print "$a\n"' #array  assignment of 
list  => 5
perl -Mwarnings -e ' $a = @a = (5,6,7); print "$a\n"' #scalar assignment of 
array => 3
perl -Mwarnings -e '($a)= @a = (5,6,7); print "$a\n"' #array  assignment of 
array => 5
perl -Mwarnings -e ' $a =    @{[5,6,7]};print "$a\n"' #scalar assignment of 
defref anon array => 3
perl -Mwarnings -e '($a)=    @{[5,6,7]};print "$a\n"' #array  assignment of 
defref anon array => 5

I actually don't like the current popular practice of doing

my ($self, $a, $b, $c)=@_;

I much prefer 

my $self = shift;
my $a    = shift;
my $b    = shift;

as I can

my $self = shift;
my $a    = shift || "default";
my $b    = shift // 0;

and actually understand what I did months later.

Mike

mrdvt92 
_______________________________________________
Houston mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/houston
Website: http://houston.pm.org/

Reply via email to