in reply to use strict and -w

Why not check if the '--' exists before doing the split?

#!/usr/bin/perl -w use strict; my $quotes = '/home/gtheys/quotes'; open(FILE, "<$quotes") || die "Badness: $quotes [$!]\n"; while (<FILE>) { chomp; my ($quote, $person); if (/--/) { ($quote, $person) = split /--/; } else { ($quote, $person) = ($_, ''); } $quote =~ s/^\s+|\s+$//g; $person =~ s/^\s+|\s+$//g; print "$quote\t$person\n"; } close FILE || die "Badness: $quotes [$!]\n";
--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: use strict and -w
by toadi (Chaplain) on Mar 15, 2001 at 15:15 UTC
    Thanx for pointing out the or die while opening and closing files. Didn't type it 'cos it wasn't the rpoblem :) But nonetheless it needs to be done...

    --
    My opinions may have changed,
    but not the fact that I am right