Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Regular Expression Matching Issue

by olus (Curate)
on Jan 02, 2008 at 21:38 UTC ( #660060=note: print w/replies, xml ) Need Help??


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!!!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://660060]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2020-07-02 09:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?