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";
"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 |