in reply to Re: Global array afftected by map inside of a subroutine
in thread Global array afftected by map inside of a subroutine
ikegami...List::MoreUtils's apply did exactly what I needed for the array. Thank you! Now all I need to figure out is why my grep is breaking.
I isolated the code that I am working on, but grep is grepping everything. I've never had this problem with grep before.
my @filesize_names = qw(bit nibble byte kilobyte megabyte gigabyte ter +abyte petabyte exabyte zettabyte yottabyte); my $word = 'fubar'; $word =~ s/s$//; my @short_sizes = apply {$_ =~ s/^(\w)\w{1,}$/$1b/} @filesize_names; print Dumper(\@filesize_names); print Dumper(\@short_sizes); if (grep(lc $word,@short_sizes)) { # even 'fubar' greps print "$word grepped!"; $word = $filesize_names[firstidx { $_ eq lc $word } @short_sizes]; } print $word;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Global array afftected by map inside of a subroutine
by BrowserUk (Patriarch) on Dec 14, 2011 at 21:36 UTC | |
by Lady_Aleena (Priest) on Dec 14, 2011 at 21:48 UTC | |
Re^3: Global array afftected by map inside of a subroutine
by kejohm (Hermit) on Dec 14, 2011 at 21:59 UTC |