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

Re: A Newbie Question, Please?

Jeff 'japhy' Pinyan
March 30, 2002 14:33
Re: A Newbie Question, Please?
Message ID:
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
RPI Acacia brother #734
** 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.  ] Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About