develooper Front page | perl.beginners | Postings from March 2002

Re: A Newbie Question, Please?

From:
Jeff 'japhy' Pinyan
Date:
March 30, 2002 14:33
Subject:
Re: A Newbie Question, Please?
Message ID:
Pine.GSO.4.21.0203301731130.6722-100000@crusoe.crusoe.net
On Mar 31, Ofir said:

>Line 1: URL
>Line 2: Time and Date
>Line 3: News Item
>Line 4: Item Source
>Line 5: URL
>Line 6: Time and Date
>Line 7: News Item
>Line 8: Item Source

>How do I parse it, since this is not a "regular" record-per-line file, but
>rather a four-line each record?

Simply read in four lines at a time.

  until (eof FILE) {
    my @lines = map scalar <FILE>, 1 .. 4;
    # work with $lines[0], $lines[1], $lines[2], and $lines[3]
  }

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About