Thanks Toolic

When i pasted the code in, some of the syntax got messed up, specifically the curly braces, but i did have the same syntax that you had

I ran what you had and it did work beautifully

ultimately, i'm trying to get the following piece of code to work. Basically, I have my date and i check it against the calendar file to see if the date is a holiday...if it does exist it means it's a holiday so i increment the date by 1 day (unless it's a sat or sun..then i increment it until it's not sat or sun..this piece of logic works), then i check the newly incremented date against the holiday file again. I repeat this until it doesn't exist in the holiday file. Then i know i have a date that's not a holiday.

The following code for some reason is not working for me. It's hitting the until loop but not entering it even if the newly incremented date is also a date in the holiday file

You may need to mock up the holiday config file with back to back holiday's to create the scenario

$date='20100101'; $new_date=get_next_bus_day($date);
until (my @date = grep !/$new_date/,@{$countries${cntry_of_issue}}) { $new_date=get_next_bus_day($new_date); }
sub get_next_bus_day { my $inc=1; my $inc4sat=2; my $inc4fri=3; my $new_date; my $date=shift; DEBUG > 1 and print "date is: >$date<\n"; my $y = substr($date,0,4); my $m = substr($date,4,2); my $d = substr($date,6,2); my $time = timelocal("", "", "", $d, $m-1, $y); if ((localtime($time))[6] == 5) { $new_date=strftime "%Y%m%d", localtime timelocal(0,0,0,$d,$m-1,$y) + +($inc4fri * 24 * 60 * 60); } elsif ((localtime($time))[6] == 6) { $new_date=strftime "%Y%m%d", localtime timelocal(0,0,0,$d,$m-1,$y) + +($inc4sat * 24 * 60 * 60); } else { $new_date=strftime "%Y%m%d", localtime timelocal(0,0,0,$d,$m-1,$y) + +($inc * 24 * 60 * 60); } return $new_date; }

Do you see any obvious reason why this wouldn't work?


In reply to Re^2: Trouble grepping values when hash contains multiple values per key by dirtdog
in thread Trouble grepping values when hash contains multiple values per key by dirtdog

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.