[This was moved from the Q&A section due to some confusion on the part of the Q&A editor and some general coding faults better discussed in SoPW]
I want to modify this so it executes on each variable
passed to it, e.g.
$c1, then
$c2,
$c3, etc. This works
for
$c1:
$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:%te
+l:%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;
}
I've been trying to do this by calling the subroutine in a
for...next loop, and passing it a variable which changes
value each time through the loop, but with no success:
for ($gi = 1; $gi <= $tno; $gi++ ) {
$tnum = "c".$gi;
$tnum2 = $query->param( '$tnum' );
@cand_info = &get_cand_info( $tnum2 );
}
I'm worn out with trying different variations on how to pass
the value(s) to the subroutine, help would be greatly
appreciated.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.