in reply to Traping [** using reg exp

Does removing the $ at the end of your regexp fix the problem? I'm assuming that given the content of the file you are parsing you are running this script in windows? Is there a \r character at the end of the line? Hint try chop($item) does it remove the ]? if not then you definately have some characters hanging around after the ] that you can't see...Droping the anchor all together will give you the most flexibility as long as the text [**REQUIRES USER CONTEXT**] can never show up anywhere but at the end.


daN.

Replies are listed 'Best First'.
Re^2: Traping [** using reg exp
by Anonymous Monk on Sep 09, 2004 at 09:59 UTC
    Adding \s befor $ at the end of the line did the trick

    This is the full script
    use strict; open (LST, "c:\\tester.txt")||die "$^E : $!\n"; chomp (my @data=<LST>); for (@data) { print "$1\n" if ($_ =~ /(.+)\[\*+REQUIRES USER CONTEXT\*+\]\s*$/); } close (LST)
    Obviously there were extra chars at the end of the line that I couldn't see.

    Thanks very much.