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
|
|---|