Correct me if I'm wrong group (I'm still a Perl novice myself), but
whenever one passes an argument to a subroutine, shouldn't one always
set local variables to $_[x]? Or at the very least add my @params = @_?

Paul: My suggestion is to add "my $param = $_[0];" as the first line of
sub buildexcel, and replace instances of $_[0] with $param. 


- Ed

-------------------------------------------------------
Edward A. Christian, Backbone Engineer
PenTeleData            email: [EMAIL PROTECTED]
540 Delaware Avenue    web: http://www.penteledata.net
Palmerton, PA 18071    phone: (800) 281-3564 x2458
-------------------------------------------------------
"Any lock can be opened, any wall can be broken...."

-----Original Message-----
From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, December 19, 2002 2:32 PM
To: Perl
Subject: if structure voiding string when condition not met?


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


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to