c has asked for the wisdom of the Perl Monks concerning the following question:
sub exec { ... ## retrieve an error message if unsuccessful my $error = $s->error if ($count > 0); ## log this action &log_action('error') if ($count > 0); ... }
now the log_action subroutine has the following line:
sub log_action { my $i = shift; if ($i eq "error") { print "\n$error\n\n"; print FH "$format $error"; ... }
i fixed this by just removing the my localization for $error outside of the subroutine to a global statement of my $error; earlier in the script. however, i just dont like the look of this declaration standing all by its lonesome. is there another/better method of passing the value of $error from subroutine to subroutine?
humbly -c
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing a variable from one subroutine to another
by Zaxo (Archbishop) on Oct 05, 2001 at 14:44 UTC | |
|
Re: passing a variable from one subroutine to another
by C-Keen (Monk) on Oct 05, 2001 at 14:18 UTC | |
|
Re: passing a variable from one subroutine to another
by jeroenes (Priest) on Oct 05, 2001 at 14:38 UTC | |
|
Re: passing a variable from one subroutine to another
by blackjudas (Pilgrim) on Oct 05, 2001 at 20:32 UTC | |
|
Re: passing a variable from one subroutine to another
by jerrygarciuh (Curate) on Oct 05, 2001 at 17:52 UTC | |
by chromatic (Archbishop) on Oct 05, 2001 at 21:29 UTC | |
by jerrygarciuh (Curate) on Oct 06, 2001 at 16:20 UTC | |
|
Re: passing a variable from one subroutine to another
by dragonchild (Archbishop) on Oct 08, 2001 at 18:06 UTC |