Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Global array afftected by map inside of a subroutine

by Lady_Aleena (Chaplain)
on Dec 13, 2011 at 22:40 UTC ( #943436=note: print w/ replies, xml ) Need Help??


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
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;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://943436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2014-07-23 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (145 votes), past polls