Re: On map

2009-11-10 Thread Uri Guttman
> "BRH" == Bryan R Harris writes: BRH> I have a curiosity maybe someone here can help with. BRH> This code: BRH>@a=(1,2); BRH>map { $_ = 3 } @a; BRH>print join(",", @a), "\n"; BRH> ... prints "3,3". That map is changing the @a array as it goes through it. BRH> G

Re: On map

2009-11-10 Thread Jim Gibson
On 11/10/09 Tue Nov 10, 2009 1:22 PM, "Bryan R Harris" scribbled: > > > I have a curiosity maybe someone here can help with. > > This code: > >@a=(1,2); >map { $_ = 3 } @a; >print join(",", @a), "\n"; > > ... prints "3,3". That map is changing the @a array as it goes through i

On map

2009-11-10 Thread Bryan R Harris
I have a curiosity maybe someone here can help with. This code: @a=(1,2); map { $_ = 3 } @a; print join(",", @a), "\n"; ... prints "3,3". That map is changing the @a array as it goes through it. Good. Now this: %a=(1,2); map { $_ = 3 } keys %a; print join(",", keys(%a)), "

Re: need help on map function

2008-07-16 Thread Brad Baxter
Weide wrote: Can anyone tell me why the map will not map out the unitialized variable in this code with 'str'? Thanks a lot, use strict; use warnings; sub total { my $firstone = shift; my $sum = 0; my $item = 0; map { defined $_ ? $_ : 'str' } @_ ; print @_; } my $hello;

Re: need help on map function

2008-07-16 Thread John W. Krahn
Rob Dixon wrote: Weide wrote: Can anyone tell me why the map will not map out the unitialized variable in this code with 'str'? Thanks a lot, use strict; use warnings; sub total { my $firstone = shift; my $sum = 0; my $item = 0; map { defined $_ ? $_ : 'str' } @_ ; print

Re: need help on map function

2008-07-16 Thread Rob Dixon
Weide wrote: > > Can anyone tell me why the map will not map out the unitialized > variable in this code with 'str'? Thanks a lot, > > > use strict; > use warnings; > > sub total > { > my $firstone = shift; > my $sum = 0; > my $item = 0; > map { defined $_ ? $_ : 'str' } @_ ; >

Re: need help on map function

2008-07-16 Thread Gunnar Hjalmarsson
Weide wrote: Can anyone tell me why the map will not map out the unitialized variable in this code with 'str'? It does. map { defined $_ ? $_ : 'str' } @_ ; print @_; You probably meant to write print map { defined $_ ? $_ : 'str' } @_ ; -- Gunnar Hjalmarsson Email: http://w

need help on map function

2008-07-16 Thread Weide
Can anyone tell me why the map will not map out the unitialized variable in this code with 'str'? Thanks a lot, use strict; use warnings; sub total { my $firstone = shift; my $sum = 0; my $item = 0; map { defined $_ ? $_ : 'str' } @_ ; print @_; } my $hello; print "not def