[Pdx-pm] Escaping a character in a string from a file

Andrew Savige ajsavige at yahoo.com.au
Wed May 12 21:55:53 CDT 2004


John <jgoalby at hotmail.com> wrote:
> I have a file of regular expressions I want to match.  I read in the file
> and then match each entry as such:
> 
> if ($something =~ /$tomatch/i)
> 
> I want to be able to specify something like ".pl" in the file so that I can
> match all perl files.  Specifying .pl matches .apl.  Is there a way I can
> escape the "." when it is in a file?  I tried "\.pl", but it didn't work.

To ensure you don't match "fred.please", use '\.pl$' -- or '\.plx?$' to
match files ending in either ".pl" or ".plx".

/-\


Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com



More information about the Pdx-pm-list mailing list