in reply to Regex Substitution in sub

If you only want to look up exact matches, you may want to stick the lookups in a hash rather than using substitutions in a subroutine (you might use your subroutine to access the hash instead). Maybe something like this?
my %interpret = ( '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 $result = "43 P"; # comes from somewhere else my $interpretation = $interpret{$result}; print $interpretation;

-- Mike

--
just,my${.02}

Replies are listed 'Best First'.
Re: Re: Regex Substitution in sub
by peppiv (Curate) on Jun 04, 2003 at 18:26 UTC
    Thank you all. The && return does work. However, I think I will work with one of the hash solutions. I believe this would be best for this application.

    SUPA THANX

    peppiv