in reply to why is this code bad under -w option?
A bit late, I imagine, but here's another way of doing it if the aim, as it appears to be, is just to convert the input string into a number:
use strict; use warnings; my %convert = ( KB => 10, MB => 20, GB => 30 ); my $num; { print "Enter the block size\n (example: 400KB,10MB,1GB): "; my $block_size = uc <STDIN>; print "Invalid block type specified!\n\n" and redo unless $block_size =~ /^(\d+)([KMG]B)$/; $num = $1 * 2 ** $convert{$2}; } print $num;
dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: why is this code bad under -w option?
by Grygonos (Chaplain) on Jul 28, 2003 at 18:31 UTC | |
by Not_a_Number (Prior) on Jul 28, 2003 at 19:02 UTC |