Sorry, I've looked at your code several times and it looks like nonsense to me. For example, it makes no sense to pass $sortby into sub ownertbl and then assign it to itself.
I suggest you start your script with:
then define all your subroutines, then your mainline (including any file-scope lexical variable declarations). For example:use strict; use warnings;
use strict; use warnings; # Put your subs here before any file-scope variables. # That makes it clearer that each sub does not depend on # anything other than the parameters passed to it. sub ownertbl { my ( $sortby, $ascdesc, $letter ) = @_; # added leading "my" # ... } # put your other subs here... # Now define your lexical variables after the subs... my ($ownsel, $sortby, $letter, $ascdesc, $t); if ( $cgi->param ) { if ( defined ( $cgi->param( 'sortby' ) ) ) { $sortby = $_; # this looks wrong to me } else { $sortby = "name"; } if (defined ( $cgi->param( 'ascdesc' ) ) ) { $ascdesc = $_; # ditto } else { $ascdesc = "desc"; } if (defined ( $cgi->param( 'letter' ) ) ) { $letter = $_; # ditto } else { $letter = " "; } ownertbl( $sortby, $ascdesc, $letter ); # now these three variables + are properly passed to the sub } else { homepage(); }
In reply to Re: passing variables to a sub
by eyepopslikeamosquito
in thread passing variables to a sub
by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |