so, i'm thinking my understanding of variables is somehow off. when i pass my ($int1, $int2) to a subroutine like somesub($int1, $int2) and call it inside the sub with ($int1, $int2) = @_ they become are not defined. to more explicit, here's extracts of my code:
my ($ownsel, $sortby, $letter, $ascdesc, $t); ... if ( $cgi->param ) { if ( defined ( $cgi->param( 'sortby' ) ) ) { $sortby = $_; } else { $sortby = "name"; } if (defined ( $cgi->param( 'ascdesc' ) ) ) { $ascdesc = $_; } else { $ascdesc = "desc"; } if (defined ( $cgi->param( 'letter' ) ) ) { $letter = $_; } else { $letter = " "; } ownertbl( $sortby, $ascdesc, $letter ); } else { homepage(); } ... sub ownertbl { ( $sortby, $ascdesc, $letter ) = @_; ... $sort = "ORDER BY " . $sortby . $ascdesc; ... print STDERR "base = $base, sort = $sort, sortby = $sortby, ascdes +c = $ascdesc, letter = $letter\n";
this is a cgi script, so from apache's error.log, i'm getting this:
Use of uninitialized value $ascdesc in concatenation (.) or string at +/var/www/cgi-bin/ownertbl.pl line 71., base = http://192.168.15.222/cgi-bin/ownertbl.pl, sort = ORDER BY name +, sortby = name, ascdesc = , letter = ,
line 71 is the $sort = "ORDER BY......" i've dealt with this before by just doing $_[0], but this is not preferred when dealing with multiple variables. where am i messing up here.
btw, this seemed relevant but didn't really answer my question:
http://perlmonks.org/index.pl?node_id=192506In reply to passing variables to a sub by ag4ve
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |