in reply to use strict and -w

Lemme see. If there's no "--", there's no person. So write the code that way:
while (<FILE>) { # no need for chomp, because you strip whitespace below if (my($quote, $person) = /(.*?)--(.*?)/s) { s/^\s+//, s/\s+$/ for $quote, $person; print "$quote\t$person\n"; } else { # no --, so just show the cleaned up quote: s/^\s+//, s/\s+$/; print "$_\t(Unknown)\n"; } }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: use strict and -w
by danger (Priest) on Mar 15, 2001 at 20:44 UTC

    Or, instead of grabbing what you want, just get rid of (or substitute) what you don't want (don't neglect the space after (Unknown) if you do want such an attribution):

    while(<FILE>){ $_ .= '-- (Unknown) ' unless /--/; s/^\s+//; s/\s+$/\n/; s/\s*--\s*/\t/; print; }