in reply to use strict and -w

I guess your problem is that if there's no $person, you get a warning of use of uninitialized value.
You could get around this by only performing the action if the variable is defined like this:
my ($quote,$person) = split /--/; $quote =~ s/^\s+|\s+$//g if defined $quote; $person =~ s/^\s+|\s+$//g if defined $person;
hth,

Jouke Visser, Perl 'Adept'

Replies are listed 'Best First'.
Re: Re: use strict and -w
by toadi (Chaplain) on Mar 15, 2001 at 15:25 UTC
    and now totally error free ... Thanx to jouke:
    #!/usr/bin/perl -w use strict; my $quotes = "/home/gtheys/quotes"; open(FILE,"<$quotes") || die "Can't open quotes file: $!"; while (<FILE>) { chomp; my ($quote,$person) = split /--/; $quote =~ s/^\s+|\s+$//g if defined $quote; $person =~ s/^\s+|\s+$//g if defined $person; if (defined $quote) {print "$quote\t"}; if (defined $person) { print "$person";} print "\n"; } close FILE || die "Can't close quotes file: $!";


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