$c1 = $query->param( 'c1' ); @cand_info = &get_cand_info( $c1 ); ..... sub get_cand_info() { my ( $c1 ) = @_; my @cand_info = (); my $pq_out; # Gather the information from a POST query. if( length($c1) == 7 ) { push( @cand_info, 'HRID' ); $pq_out = `/opt/bin/pq -o '%last:%first:%loc:%room:%tel:%id' hrid=$c1`; } chomp $pq_out; # Put the data into the list. @cand_info = ( @cand_info, split(/:/, $pq_out) ); ($cand_info[1] = $cand_info[1]) =~ s/_/ /g; # name massage return @cand_info; } #### for ($gi = 1; $gi <= $tno; $gi++ ) { $tnum = "c".$gi; $tnum2 = $query->param( '$tnum' ); @cand_info = &get_cand_info( $tnum2 ); }