Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: sequential file handling

by maverick (Curate)
on May 30, 2002 at 23:07 UTC ( #170545=note: print w/ replies, xml ) Need Help??


in reply to sequential file handling

Here's how to do just the 'round robin' part.

my @dirs = qw{ dir1 dir2 dir3 }; my $num_targets = $#dirs + 1; my $counter = 0; foreach (0..10) { my $target = $dirs[$counter % $num_targets]; print "$_ => $target\n"; $counter++; }
The % operator gives you the remainder of the division of $counter / $num_targets, which will be 0, 1 or 2 for any value of $counter. Use that number to select the proper directory out of the array.

Run this little snippet and you can see the result...

/\/\averick
OmG! They killed tilly! You *bleep*!!


Comment on Re: sequential file handling
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://170545]
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: (8)
As of 2015-07-07 01:06 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 (86 votes), past polls