Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Search and replace with a wild card

by jbware (Chaplain)
on Aug 24, 2004 at 17:04 UTC ( [id://385454]=note: print w/replies, xml ) Need Help??


in reply to Search and replace with a wild card

Like the others, I was a bit confused by the exact request. But here is another solution that returns the #s, which I'm wondering is what you want.
my %xref; $xref{'NAME'} = 'NAME'; $xref{'DESC'} = 'DECSRIPTION'; $xref{'DATE'} = 'DATE'; while (<DATA>) { # s/(NAME|DESC|DATE)(\d*)/$xref{$1}/eg; s/(NAME|DESC|DATE)(\d*)/$2/g; print; } __DATA__ NAME010 DESC025 DATE009 NAME011 DESC035 DATE009


-jbWare

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-25 17:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found