No such thing as a small change | |
PerlMonks |
Re: finding { and }by higle (Chaplain) |
on Oct 17, 2001 at 00:51 UTC ( [id://119252]=note: print w/replies, xml ) | Need Help?? |
There are two problems with your script: One (the main problem), when you are opening the file that you wish to read from, i.e. open (FIL, ">>$FILE") || die $!;, you are using the append operator (>>) on the $FILE, instead of the read (<) operator. This will not allow you to read in the file line by line, in fact it will not allow you to read the file at all. Two, as already pointed out, the regexes are problematic. You're using single quotes as delimiters, instead of the standard forward slash (which is allowable), but to do so you have to put m in front of the first single quote, i.e. $word =~ m'}' to let Perl know that you're going to use something other than the forward slash. Or you could just use a forward slash, $word =~ /}/. And you have to put a backslash in front of the "{", because it's a quantifying metacharacter. Here is a rewrite of your script that should work:
higle
In Section
Seekers of Perl Wisdom
|
|