Apologies I miss read the original remark. -----Original Message----- From: Chas Owens [mailto:[EMAIL PROTECTED] Sent: 16 August 2007 10:12 To: Andrew Curry Cc: Dr.Ruud; beginners@perl.org Subject: Re: One liner to change one line
On 8/16/07, Andrew Curry <[EMAIL PROTECTED]> wrote: snip >> Many s/$search/replace/ constructs should have been written with >> quotemeta, so that they look like: >> >> s/\Q${search}/replace/ snip > Why? snip given my $search = "file.txt"; What do you want matched? Without the quotemeta it would match "fileAtxt", this is not normally the behavior you desire. Basically it all comes down to this: always use quotemeta unless the variable is known to contain the string form of a regex. Also, it is a good idea to note the end of the quotemeta like this s/\Q${search}\E/replace/ This e-mail is from the PA Group. For more information, see www.thepagroup.com. This e-mail may contain confidential information. Only the addressee is permitted to read, copy, distribute or otherwise use this email or any attachments. If you have received it in error, please contact the sender immediately. Any opinion expressed in this e-mail is personal to the sender and may not reflect the opinion of the PA Group. Any e-mail reply to this address may be subject to interception or monitoring for operational reasons or for lawful business practices. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/