Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Variables in Regular Expressions?

by damian1301 (Curate)
on Apr 25, 2001 at 23:37 UTC ( #75579=note: print w/ replies, xml ) Need Help??


in reply to Variables in Regular Expressions?

This is what I used, and yes it does work.

#!/usr/bin/perl $a = "abc"; $b = "def"; $c = "abc leppard"; $c =~ s/$a/$b/; print $c;


I didn't think you could transliterate on that so I tried it and then tried a substitution. To my avail, it worked.
Just so all these other monks that think a transliteration will work, this is what I got when I ran it as  tr/$a/$b/;

bbc leppbrd
Which, I doubt is what he wanted.

PS: May I ask what ~= is? I think you mean =~. :)

UPDATE: It seems that everyone likes to answer this in a minute's time. Chady and some other monk already beat me to it :)

Tiptoeing up to a Perl hacker.
Dave AKA damian


Comment on Re: Variables in Regular Expressions?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (11)
As of 2014-08-20 15:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (116 votes), past polls