Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Regex Substitution in sub

by pzbagel (Chaplain)
on Jun 04, 2003 at 18:16 UTC ( [id://263093]=note: print w/replies, xml ) Need Help??


in reply to Regex Substitution in sub

The regex should say what you want to match, you don't do that so after the /P/ gets substituted the T fires on 'T'unnel. instead of the T after the P. Try:

$_[0] =~ s/43 F/Tunnel 1\/2 Hr FT/o; $_[0] =~ s/43 P/Tunnel 1\/2 Hr PT/o; $_[0] =~ s/45 F/Tunnel No Lunch FT/o; $_[0] =~ s/45 P/Tunnel No Lunch PT/o; $_[0] =~ s/F(.$)/Full Time No Clock $1/o; $_[0] =~ s/O(.$)/On Call No Clock $1/o; $_[0] =~ s/P(.$)/Part Time No Clock $1/o; $_[0] =~ s/T$/Temporary No Clock/o;

I don't know whether O is the first or second of the two character code you are substituting, I guessed it was the first char. Anyhow, it you tell it to substitute T at the end of the string, you get what you want.

Hope this gets you closer to your goal.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2024-03-29 08:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found