How to get a computed string to act as a re in if statement



Hi

I am working on the sub below.

The aim is to create a string from values passed to the sub-routine
and then use that as a if criterion for the push operation.

Is this possible?



sub get_list {
my ($black_list,$table,$crit)=@_;

### $crit is a hash reference containing key to search and search

expression, for example start=Jul 07 ###
my $listings;

#### This is a loop through hash containing key, value pairs of field,
value and placing into an array ####


foreach my $keys (keys %{$crit}){
push @crit,'{'."'".$keys."'".'}=~'.$crit->{$keys};
}


my $crit1=join ' and ',@crit; ### array to string ###


### This is the record definition from a master hash ###
###loop start ###


foreach my $guides (sort {$guide{$a}->{'start'} <=>
$guide{$b}->{'start'}} keys %guide){
push @{$listings},[$guide{$guides}->{'id'},$guide{$guides}->{'Channel'},substr($guide{$guides}->{'start1'},0,16),$guide{$guides}->{'start'},substr($guide{$guides}->{'stop1'},0,16),$guide{$guides}->{'stop'},$guide{$guides}->{'name'},$guide{$guides}->{'cat0'}]


### here I want an if statement to run that is generated depending on
what keys are in the oringinal %crit hash. Number of arguments
variable ###


if $crit1;

# this is the problem rather than searching on the value of
$guide{$guides}-> it prints it out as a literal


} #### loop end ###


}
.



Relevant Pages

  • RE: null values
    ... a similar problem was save all new sth's in a hash. ... # from a package that builds a sub class of a DBI object.... ... be advised that the prepare statement is NOT in the Column loop. ... Not a good deal if your app typically does 10 executes. ...
    (perl.dbi.users)
  • Re: sorting and resorting hash
    ... There's no reason to be adding values to an array if you're only using ... Just build the hash directly. ... of the entire %rms hash each time through the loop. ... Why are you creating a whole new array to just store the keys of the hash ...
    (comp.lang.perl.misc)
  • Re: multiline matching
    ... > City: Austin ... You never had more than one entry in the hash at a time. ... The for loop below is in the wrong spot. ... That loop fetches all the keys of the hash and then prints the Name, ...
    (perl.beginners)
  • Re: writing get_script()
    ... A quick search for 'Binary Tree" on CPAN returns several hundred ... the hash then extract the keys. ... the key and immediately uses its value, which is "undef", so the loop ...
    (comp.lang.perl.misc)
  • Re: help with regex
    ... I'm using the %data hash to store information about each ... Each start hash has two keys, ... data structures can be used, particularly for the last level, but I ... sub print_start ...
    (comp.lang.perl.misc)