develooper Front page | perl.beginners | Postings from December 2002

if structure voiding string when condition not met?

Thread Next
From:
Paul Kraus
Date:
December 19, 2002 11:32
Subject:
if structure voiding string when condition not met?
Message ID:
018801c2a795$560e7930$64fea8c0@pkrausxp
When I run this code

&buildexcel("Age");
...
sub buildexcel{
    ...
    my $sheet=$book->worksheets('AgeRaw') if ($_[0] eq "Age");
    my $sheet=$book->worksheets('ReceiptsRaw') if ($_[0] eq "Cash");
    $sheet->activate();
    ...
}

I get this error
...
Can't call method "activate" on an undefined value at armonth.pl line 92
<AGE> line 17904.

If I comment out
my $sheet=$book->worksheets('ReceiptsRaw') if ($_[0] eq "Cash");
then it executes correctly.

This is really confusing me since the only thing being passed to the
subroutine is "Age" so the "Cash" if should never ever execute. But it
seems that it is checking it and then setting $sheet to null or
something when the condition comes back false.

I am 
Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About