I originally posted this to my use.perl journal, but once again, I realized some monks might enjoy this.
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>; }
If you post the answer, do so as a spoiler, please.
Cheers,
Ovid
New address of my CGI Course.
In reply to Spot the Bug by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |