in reply to Re: Global array afftected by map inside of a subroutine
in thread Global array afftected by map inside of a subroutine

I'm using Strawberry Perl 5.10 for Windows XP.

Have a cookie and a very nice day!
Lady Aleena
  • Comment on Re^2: Global array afftected by map inside of a subroutine

Replies are listed 'Best First'.
Re^3: Global array afftected by map inside of a subroutine
by chromatic (Archbishop) on Dec 13, 2011 at 23:02 UTC

    Then you need something like:

    my @short_sizes = map { my $item = $_; $item =~ s/^(\w)\w{1,}$/$1b/; $item } @in_sub_filesize_names;

    Improve your skills with Modern Perl: the free book.

Re^3: Global array afftected by map inside of a subroutine
by runrig (Abbot) on Dec 14, 2011 at 00:16 UTC
    In map, grep, and in "for" loops, $_ is an alias to the current item, so this would work also:
    my @short_sizes = @in_sub_filesize_names; s/^(\w)\w{1,}$/$1b/ for @short_sizes;