http://qs321.pair.com?node_id=660060


in reply to Regular Expression Matching Issue

I didn't check the regular expression in order to see if did what you it to do, but I see that you trying to use it as if was applied to the _whole_ file, and you are using it only for a single line each time. The 's' switch isn't working because you are working on a single line.

'join' @test and work on that, or change the foreach cicle and look for lines that have the block begin, capture everything until you find another line that matches the block ending.

Replies are listed 'Best First'.
Re^2: Regular Expression Matching Issue
by Punitha (Priest) on Jan 03, 2008 at 04:06 UTC

    I agreed with olus

    You can 'join' @test or while reading from the file itself you can read the whole file in single scalar variable using undef as.

    open(FH,'<',$new_file) || die $!; do {local undef $/;$test = <FH>}; close(FH); while($test =~ /<!--\s+\d+nd table -->\s*(.*?)\s*<!--\s+\/\d+nd table +-->/sgi){ $out_put = $1; print "$out_put\n"; }

    I think this code is matching what did you expected

    Punitha

      Thanks, it works like that!!!