Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 meditating upon the Monastery: (6)
As of 2014-12-27 19:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls