Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

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

by kejohm (Hermit)
on Dec 14, 2011 at 21:59 UTC ( #943622=note: print w/ replies, xml ) Need Help??


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

Based on your code sample, might I suggest a hash lookup table, eg:

# Untested my @filesize_names = qw(kilobyte megabyte gigabyte terabyte petabyte e +xabyte zettabyte yottabyte); my %short_sizes = map { m/^(\w)/; $1 . 'b' => $_ } @filesize_names; my $word = 'kb'; if ( exists $short_sizes{lc $word} ) { say $short_sizes{lc $word}; }


Comment on Re^3: Global array afftected by map inside of a subroutine
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (13)
As of 2015-07-29 21:15 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 (269 votes), past polls