Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by Lady_Aleena (Deacon)
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: (7)
As of 2015-07-02 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls