The loop works, however the checks have not been added. If I add a next if, or if statement it will make a single loop and exit the sub. Broken code - only performs single loop.sub check_activity { # check activity - Exceptions, Failures, Active, Queued, Repli +cation ## defaults ## my $lresults = {}; my $WEEK = time - (7 * 24) * 3600; # time a week ago... ## passed ## my $lacts = shift; my $lyester = shift; my $act; print "here in check activity\n"; #print "keys - " . join(',', keys %{$lacts}) . "\n"; foreach $act ( keys %{$lacts} ) { print "$act - $lacts->{$act}->{Status} - $lacts->{$act +}->{Type} - $lacts->{$act}->{StartTime} - $lyester\n"; } return $lresults; } OUTPUT: here in check activity cut....cut 9132184440017109 - Completed w/Exception(s) - Scheduled Backup - 2011- +11-20 19:00 PST - 2011-11-22 14:54:12 9132192720051109 - Completed - Scheduled Backup - 2011-11-21 18:17 PST + - 2011-11-22 14:54:12 9132201360045609 - Completed - Scheduled Backup - 2011-11-22 18:05 PST + - 2011-11-22 14:54:12 1321898408398257 - Completed - Replication Source - 2011-11-21 10:00 P +ST - 2011-11-22 14:54:12 9132192720002809 - Timed Out - Start - Scheduled Backup - 2011-11-21 1 +8:00 PST - 2011-11-22 14:54:12 cut...cut
Any thoughts or advice is greatly appreciated. - Chucksub check_activity { # check activity - Exceptions, Failures, Active, Queued, Replicati +on ## defaults ## my $lresults = {}; my $WEEK = time - ( 7 * 24 ) * 3600; # time a week ago... ## passed ## my $lacts = shift; my $lyester = shift; my $act; print "here in check activity\n"; #print "keys - " . join(',', keys %{$lacts}) . "\n"; foreach $act ( keys %{$lacts} ) { print $act . " - " . $lacts->{$act}->{Status} . "\n"; next if $lacts->{$act}->{Status} =~ /Completed$/; print "$act - $lacts->{$act}->{Status} - $lacts->{$act +}->{Type} - $lacts->{$act}->{StartTime} - $lyester\n"; } return $lresults; } OUTPUT: here in check activity 9132201720006509 - Completed
In reply to Adding "if" statement to foreach causes only 1 run by TheChuckMo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |