Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.
Late at night, lots of coding and a little test program confused me for a moment until I looked at it again and almost laughed myself silly. I needed to test that I could read individual records in a file. The records are separated by a lone dot "." appearing by itself on a line. My intention was to open the file, read in individual records, remove that trailing dot and visually inspect the records one by one. Spot the bug:
#!/usr/bin/perl
use strict;
use warnings;
my $file = shift || die "No file, dummy!";
open FH, "<", $file or die "Could not open ($file) for reading: $!";
local $/ = "\n.\n";
while (defined (my $record = <FH>)) {
chomp $record;
print $record;
<STDIN>;
}
Moral of this story: don't code while tired.
That's a fun bug! (Score:1)
Re:That's a fun bug! (Score:2)
Yup. That's it. In my case, I was reading in a huge file so I didn't want to slurp it all in at once. I went for the following fix:
Re:That's a fun bug! (Score:1)
Re: (Score:1)
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 isRe: (Score:2)
this should be a property of the filehandle, not a global variable.
Perl 6, baby, Perl 6.