Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
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}; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://943622]
help
Chatterbox?
[stevieb]: daughter arrived from SF with Gandalf the bunny for his first international flight. Very wonderful Friday... like the holidays came early :)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2016-12-03 04:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (52 votes). Check out past polls.