multiline pattern matching from file

Discussion in 'Perl Misc' started by Giulio, Jan 22, 2007.

  1. Giulio

    Giulio Guest

    hi,

    I am developing a script for extracting data from some webpages I got
    with wget.
    I am using pattern matching to extract a list of items from the file.
    Each item is composed by several properties, contained on different
    lines of the page, which must be kept together (they're of course in
    order and there's a multiline pattern to find them out one by one).

    so far I arrived to the code (at the end of the msg) that matches
    greatly, but data on single lines of the pages.

    how can I do this pattern matching from the file and obtain the full
    multiline pattern?

    thanx
    G

    ------------------
    open (FILE, "<$file") || die("error in opening file");

    while ($f = <FILE>) {
    if ($f =~ /^.*<a href="\/photos\/(.*)\/(.*)\/" title="(.*)">/ ) {
    $userName = $1;
    $imageCode = $2;
    ------------------
     
    Giulio, Jan 22, 2007
    #1
    1. Advertising

  2. Giulio <> wrote:

    > Each item is composed by several properties, contained on different
    > lines of the page,



    > how can I do this pattern matching from the file and obtain the full
    > multiline pattern?



    I'd start with the official answer to your Frequently Asked Question:

    perldoc -q match

    I’m having trouble matching over more than one line. What’s wrong?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Jan 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. danpres2k
    Replies:
    3
    Views:
    7,481
    danpres2k
    Aug 25, 2003
  2. Marc Bissonnette

    Pattern matching : not matching problem

    Marc Bissonnette, Jan 8, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    238
    Marc Bissonnette
    Jan 13, 2004
  3. dale zhang
    Replies:
    8
    Views:
    430
    Tintin
    Nov 30, 2004
  4. Bobby Chamness
    Replies:
    2
    Views:
    235
    Xicheng Jia
    May 3, 2007
  5. nani
    Replies:
    2
    Views:
    170
    comp.llang.perl.moderated
    Mar 14, 2008
Loading...

Share This Page