toadi has asked for the wisdom of the Perl Monks concerning the following question:
But the problem is that in the textfile I open there's not always a -- to split because there's no name.#!/usr/bin/perl -w use strict; my $quotes = "/home/gtheys/quotes"; open(FILE,"<$quotes"); while (<FILE>) { chomp; my ($quote,$person) = split /--/; $quote =~ s/^\s+|\s+$//g; $person =~ s/^\s+|\s+$//g; print "$quote\t$person\n"; } close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use strict and -w
by davorg (Chancellor) on Mar 15, 2001 at 14:54 UTC | |
by toadi (Chaplain) on Mar 15, 2001 at 15:15 UTC | |
|
Re: use strict and -w
by Jouke (Curate) on Mar 15, 2001 at 14:56 UTC | |
by toadi (Chaplain) on Mar 15, 2001 at 15:25 UTC | |
|
Re: use strict and -w
by busunsl (Vicar) on Mar 15, 2001 at 14:45 UTC | |
|
Re: use strict and -w
by merlyn (Sage) on Mar 15, 2001 at 19:58 UTC | |
by danger (Priest) on Mar 15, 2001 at 20:44 UTC | |
|
Re: use strict and -w
by extremely (Priest) on Mar 16, 2001 at 02:35 UTC |