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


Comment on Re^4: How to skip certain values in a foreach loop
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://879437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2015-07-07 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls