Clearly your regular expression just slurped the whole end of the file, rather than finding an end of line character.
In dos the default end of line character (which is actually two characters) is "\r\n", so it may be that the dos perl expects both of those characters to end the file. If you took your text file from linux and transferred it using a binary copy of some form, then your text file would still be in linux format, and would either need to be converted to dos (in standard linux you can do a dos2unix and unix2dos commands to convert between the two... at least I can on my redhat system...)
You can also change the end of line character that perl's searching for... okay so I'm calling it the wrong thing, it's really called the $INPUT_RECORD_SEPARATOR, or is called $/ in perl. Instead of it being set to \r\n, just set it to \n.
The other possibility is that there's a default in the regex. If that's the case, anchor your regex.
Instead of looking for m/particularly(.*)/ look for m/particularly(.*)$/
The $ says "go to the end of line" ($/ character sequence). It's a good practice to anchor your regexes if you want to garantee you're going to the end of a line, rather than slurping the whole file.
Hope that helps,
--Ray
In reply to Re: Find strings
by raybies
in thread Find strings
by toros
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |