Thanks for the response
If I have to pass other variables that are not a part of the $query object, I presume that I should be passing that to the subroutine.
Please look at the modified code below:- Any suggestions?
use CGI; my $query = CGI->new(); # get the data structure my $ref_data= create_data_structure(); if ($query->param( "button" ) eq 'first') { display_first( $query, $ref_data ) } else { display_second( $query, $ref_data ) } sub display_first { my ( $query, $s1_data ) = @_; # declare your variables here ... # use $s1_data to do something in this sub } sub display_second { my ( $query, $s2_data ) = @_; # declare your variables here ... # use $s2_data to do something in this sub } sub create_data { ... create a hash data structure ... ... return \%hash; }
In reply to Re^2: CGI: Passing variables to a subroutine
by stumbler
in thread CGI: Passing variables to a subroutine
by stumbler
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |