in reply to Regex Substitution in sub
If your codes are that exact, do a hash lookup instead:
sub interpret_clock { my %codes = ( '43 F' => 'Tunnel 1/2 Hr FT', '43 P' => 'Tunnel 1/2 Hr PT', '45 F' => 'Tunnel No Lunch FT', '45 P' => 'Tunnel No Lunch PT', 'F' => 'Full Time No Clock', 'O' => 'On Call No Clock', 'P' => 'Part Time No Clock', 'T' => 'Temporary No Clock', ); my $code = shift; unless (exists $codes{$code} ) { die "Unknown code: ($code)"; } return $codes{$code}; }
You're much less likely to be in error with that.
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Regex Substitution in sub
by Juerd (Abbot) on Jun 04, 2003 at 18:51 UTC | |
by Ovid (Cardinal) on Jun 04, 2003 at 19:07 UTC |