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

Re^2: split on every n lines

by hbm (Hermit)
on Apr 11, 2014 at 01:52 UTC ( #1081902=note: print w/replies, xml ) Need Help??


in reply to Re: split on every n lines
in thread split on every n lines

#!/usr/bin/perl use strict; use warnings; open my $fh, '<', 'list.txt' or die $!; chomp(my @hosts = <$fh>); close $fh; while (my @five = splice @hosts, 0, 5) { print qq{command @five\n}; } # prints: command host1 host2 host3 host4 host5 command host6 host7 host8 host9 host10 command host11 host12

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (1)
As of 2021-09-18 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?