Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Hehe. I did spot it without running the code – after I stepped out of the box and started thinking about what things it does other than its primary goal. It took about three minutes of staring.

    I can’t think of a solution that is compact, non-obfuscatory, and avoids redundancy (ie setting $/ twice) all at once. The best I can do is

    while( 1 ) {
        do {
           local $/ = "\n.\n";
           my $record = <FH>;
           last if not defined $record;
           chomp $record;
           print $record;
        };
        <STDIN>;
    }

    The tricky bit in reformulating this is that the new record separator has to be in scope for both the readline as well as the chomp. Perl5 is definitely kludgy here – this should be a property of the filehandle, not a global variable.

    • this should be a property of the filehandle, not a global variable.

      Perl 6, baby, Perl 6.