Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts

    grep causing an error in output - no.. it was my brain

    Hi,
    Edit:
    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.

    Code:
    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
    Last edited by bazz; 10-13-2009 at 08:51 AM.
    "The day you stop learning is the day you become obsolete"! - my late Dad.

    Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
    Useful MySQL resource
    Useful MySQL link


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •