Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: help needed with match multiple lines

by olus (Curate)
on Jun 20, 2008 at 17:39 UTC ( [id://693193]=note: print w/replies, xml ) Need Help??


in reply to help needed with match multiple lines

When you undef $/; you'll read everything at once, so the while is not doing what I think you expect it to do.

I wrote the following example based on your regexp and slightly modified it to give the result that I believe are as expected.

use strict; use warnings; use Data::Dumper; #my @array = <DATA>; #my $text = join '', @array; undef $/; my $text = <DATA>; my @matches = $text =~ m{class="report".*?&id=1">\s*(.*?)</a.*?"report +"\swidth.*?>\s*(.*?)\s*</td>}sgx; print Dumper(\@matches); __DATA__ <td class="report"> <a href="blahblah1&id=1">link to blah 1</a> </td> <td class="report" width=50> cell2 1 </td> <td> some other stuff </td> <td class="report"> <a href="blahblah2&id=1">link to blah 2</a> </td> <td class="report" width=50> cell2 2 </td>

That outputs:

$VAR1 = [ 'link to blah 1', 'cell2 1', 'link to blah 2', 'cell2 2' ];

Now you can iterate through the resulting array in pairs of two. Hope that helps.

Replies are listed 'Best First'.
Re^2: help needed with match multiple lines
by Anonymous Monk on Jun 20, 2008 at 17:59 UTC
    Hi,

    Thank you very much for your help. I followed your codes(adding the directory part), but still keep running (problem of my directory loop?? )...
    I am not sure what is the problem..
    Thanks again!
    Joice

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found