Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: How to skip certain values in a foreach loop

by samarzone (Pilgrim)
on Dec 28, 2010 at 14:31 UTC ( #879437=note: print w/replies, xml ) Need Help??


in reply to Re^3: How to skip certain values in a foreach loop
in thread How to skip certain values in a foreach loop

You should improve the structure of $vars. You have n values in @AdminTime and 5*n values in @AdminEndDate 5 for each value of @AdminTime. Right!!!
You should keep only 5 values in @AdminEndDate, each an arrayref for all five deadlines of a day in @AdminTime. Now your @AdminEndDate array index will be same as that of @AdminTime.

For example you have @AdminTime as ('day1', 'day2', 'day3') and @AdminEndDate as

({AppEnd => 'dl1'}, {AppEnd => 'dl2'}, {AppEnd => 'dl3'}, {AppEnd => 'dl4'}, {AppEnd => 'dl5'}, {AppEnd => 'dl6'}, {AppEnd => 'dl7'}, {AppEnd => 'dl8'}, {AppEnd => 'dl9'}, {AppEnd => 'dl10'}, {AppEnd => 'dl11'}, {AppEnd => 'dl12'}, {AppEnd => 'dl13'}, {AppEnd => 'dl14'}, {AppEnd => 'dl15'})

Make your @AdminEndDate array like
([{AppEnd => 'dl1'}, {AppEnd => 'dl2'}, {AppEnd => 'dl3'}, {AppEnd => +'dl4'}, {AppEnd => 'dl5'}], [{AppEnd => 'dl6'}, {AppEnd => 'dl7'}, {AppEnd => 'dl8'}, {AppEnd => ' +dl9'}, {AppEnd => 'dl10'}], [{AppEnd => 'dl11'}, {AppEnd => 'dl12'}, {AppEnd => 'dl13'}, {AppEnd = +> 'dl14'}, {AppEnd => 'dl15'}]

You can now run a loop from index 0 to $#AdminTime and use the index number for both the arrays. You'll, however, have to modify your template code a little to dereference the inner array references of all five values corresponding to each day

--
Regards
- Samar

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://879437]
help
Chatterbox?
[ambrus]: Ok, but if there's a POE integration, then I again suggest that you consider using IO::Async::Loop:: Poe . I don't know if that will work.
[ambrus]: So that, or if you really want something agnostic to the loop, then use curl multi. Its interface is quite reasonable (unless you use an old version),
[ambrus]: though it's very C-like (serious use of varargs so easy to pass the wrong type), and there are some minor problems (busy loop because it doesn't use the same timer as your event loop, so you have to artificially delay timer callbacks by a small amount).

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2016-12-07 16:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (130 votes). Check out past polls.