in reply to Reducing repetitive code
my %months; @months{1..12} = qw/January February March April May June July August September October November December/; my $numeric_month = "01"; # Test case. my $string_month; $numeric_month =~ s/0(\d)/$1/; if ( exists( $months{$numeric_month} ) ) { $string_month = $months{$numeric_month} } else { die "Invalid month format.\n"; }
Dave
|
|---|