Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Regex Substitution in sub

by thelenm (Vicar)
on Jun 04, 2003 at 18:18 UTC ( [id://263096]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263096]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-03-19 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found