NodeReaper has asked for the wisdom of the Perl Monks concerning the following question:

This node was taken out by the NodeReaper on May 26, 2021 at 21:47 UTC

You may view the original node and the consideration vote tally.

  • Comment on Reaped: (duplicate) Reading HTML? (delete)

Replies are listed 'Best First'.
Re: Reading HTML?
by TGI (Parson) on Sep 05, 2001 at 04:36 UTC
    what does your code do? Let's see.
    while (<'FILE'>) { $gline = <'FILE'>; print $gline; }

    Line 1. while(<'FILE'>)

    The <> operator takes a chunk of input from a filehandle, and assigns it to a variable. In this case, to $_, our favorite line noise default variable. So you have said, 'While you can pull a hunk of data out of FILE and stick it into $_, do some stuff.'

    Line 2. { $gline = <'FILE'>;

    Again with <>. This time you're explicitly assigning to $gfile. To translate into english, 'Put the next hunk of data you get from FILE into $gline.'

    Line 3.  print $gline;

    Simply print the contents of $gline, which in this case is the even lines of your file.
    Try this code ;)

    while (<FILE>) { $gline = <FILE>; push @even, $gline; } seek FILE, 0,0; do { $gline = <FILE>; push @odd, $gline; } while (<FILE>); foreach(0..$#odd) { print $odd[$_], $even[$_]; }


    TGI says moo