Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How check if a $variable is in a @table ?

Status
Not open for further replies.

PasPy

Programmer
May 16, 2002
11
CA
for exemple; if I send a param like /.../exemple.cgi?offer=36

in the sub, I want to check if 36 is in a @table,...

like
@table = (`value1`,`value2`,...,`valueN`)
#I want know if $param = anyone of the @table value
if $param != @table {
#then add it to the table (for exemple)
}

I want also know how to add an item to a @table,

like @table = @table + $NewValue


Thanks, the help I received thru this forum was very helpful
 
First I would put 'offer' in a variable.
#!/to/perl
use CGI;
$query = new CGI;
$found = "no";
@table = (`value1`,`value2`,...,`valueN`);
$lookfor = $query->param('offer');
foreach $i(@table)
{
if($lookfor eq $i)
{
$found = "yes";
}
}
push(@table,$lookfor); #add to end of array
pop(@table, $lookfor); #add to beginning of array
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top