I have file (node_list.txt) which is having list of nodes.
nod_1
nod_2
nod_3
nod_4
nod_5
I have list of host ip address(this count may vary) and need to devide the node_list into equal number of parts and send those splitted node files to each of the hosts. host_ip1 host_ip2 host_ip3
Dividing of nodes in the file are based on number of host_ip's available.
Here in my example I should get:
node_list_file_1.txt
nod_1
nod_2
node_list_file_2.txt
nod_3
nod_4
node_list_file_3.txt
nod_5
My code looks like this:
print Dumper(\@list_of_hosts);
my $node_file = "node_list.txt";
open(NODE_FILE, "< $node_file") or die "can't open $node_file: $!";
my $count;
$count += tr/\n/\n/ while sysread(NODE_FILE, $_, 2 ** 16);
print "COUNT:$count\n";
my $res = $count / scalar @list_of_ips;
In $res
I am getting the count how much number of lines should go to each of the file. But how to put this into file.