...

View Full Version : Resolved grep causing an error in output - no.. it was my brain



bazz
10-13-2009, 09:45 AM
Hi,

Oh how I hate the way my brain doesn't get something until after I have posted. I had a 'return later in the script which was (obviously) stopping the loop.


Can't seem to get to the bottom of this.

It seems that the 'grep' is not doing as I thought. It is meant to make sure that the $tariff_id is in the array @tariff_to_use so that the script only uses the correct tariffs.



print qq( attu=@tariff_to_use <br /> ); # 85 88 ~ correct

foreach my $tariff_id ( sort keys %tariff_to_terms ) {
print qq( tariff_id=$tariff_id<br /> ); # outputs 85 88 ~ correct

if ( grep /$tariff_id/, @tariff_to_use ){

my $number_of_nights_this_tariff = $nights_per_tariff{$tariff_id};

print qq( nontt=$number_of_nights_this_tariff :: tariff_id=$tariff_id <br /> ); # only outputs 85 ~ should also output 88



what am I missing?

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum