Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: reg. expr. multiple substitutions

by Eliya (Vicar)
on May 17, 2012 at 14:06 UTC ( #971064=note: print w/replies, xml ) Need Help??


in reply to reg. expr. multiple substitutions

You could alias $_ to $str, which would allow you to at least get rid of the repetitive "$str =~ " part in every line.

Other than that, you do have to declare somehow what to replace with what, and this get can hardly get any more compact than a list of s/.../.../ (unless there is some pattern or regularity in the tag-substitution pairs that would allow you generate them automatically — but I suppose the ones given are not the real ones).

for ($str) { s/tag1/subst1/; s/tag2/subst2/; s/tag3/subst3/; ... s/tag49/subst49/; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971064]
help
Chatterbox?
[stevieb]: can anyone recommend a good IDE for C programming that has *proper* vim plugin support? I've tried Eclipse, Netbeans etc and just can't get anything to work properly on Linux. I'm open to paying, but not on some monthly/yearly plan (just a one-off cost)
[stevieb]: I'd go with CLion as it's very similar to what I use already (intelliJ for Perl, Pycharm for Python), but it's a recurring fee every year

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2017-01-18 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (163 votes). Check out past polls.