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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |