On Tue, 30 Sep 2014 14:08:14 -0700
SSC_perl <p...@surfshopcart.com> wrote:

>       Is the output of these two lines equivalent?
> 
> map { $hash->{$_} = shift @record } @{$self->{'FIELDNAMES'}};
> 
> $hash->{$_} = shift @record foreach @{$self->{'FIELDNAMES'}};
> 
>       They appear to be in my testing, but I'd like to make sure.
> 
>       Is one more appropriate than the other in a situation like
> this, or is it simply a styling difference?

Fancy tricks are fine...if you understand them. But do yourself a
favour: code like you will have to read it after an all-night party
(some day, you will).

foreach my $field_name ( @{ $self->{FIELDNAMES} } ){
  $hash->{ $field_name } = shift @record;
}

In other words, keep is simple.


-- 
Don't stop where the ink does.
        Shawn

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to