
shawnhcorey
Enthusiast

Sep 21, 2009, 6:28 AM
Post #2 of 2
(4592 views)
|
Re: [sysprogerz] I found bug in perl, do you know the workaround?
[In reply to]
|
Can't Post
|
|
Hello, I am making this batch file : as.sh find="aaa"; perl -pi -e 's/$find/zzz/g' as.txt and this file: as.txt aaabbbccc When i run the as.sh, it gives : zzzaaabbbccc It is supposed to replace aaa with zzz, anyone knows why? thx Yes. Oh, you want to know why too? perl -pi -e "s/$find/zzz/g" as.txt Using single quotes means $find is not expanded so perl sees: perl -pi -e 's//zzz/g' which means subsitute at the first opportunity, which is the beginning of the line. __END__ I love Perl; it's the only language where you can bless your thingy. Perl documentation is available at perldoc.perl.org. The list of standard modules and pragmatics is available in perlmodlib. Get Markup Help. Please note the markup tag of "code".
|