Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2016-09-30 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (571 votes). Check out past polls.