G'day sunil9009,
You can do that like this:
#!/usr/bin/env perl use strict; use warnings; use autodie qw{:all}; my $hosts = 2; my $tool = 'echo'; my @cmd = ($tool); while (<DATA>) { chomp; push @cmd, $_; if ($. % $hosts == 0) { system @cmd; @cmd = ($tool); } } system @cmd if @cmd > 1; __DATA__ host1 host2 host3 host4 host5
Output:
host1 host2 host3 host4 host5
-- Ken
In reply to Re: split on every n lines
by kcott
in thread split on every n lines
by sunil9009
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |