Rewrite users.pl
Jump to navigation
Jump to search
#!/usr/bin/env perl # # $Id:$ # #------------------------------------------------- @types = ('backline', 'frontline', 'teamlead', 'operations'); @nodes = ('node1', 'node2', 'node3', 'node6'); $no_nodes = $#nodes + 1; printf "Building data for %d nodes\n", $no_nodes; #---- Rewrite ------------------------------------ foreach $type (@types) { $in = sprintf("users_%s_node1.dat", $type); $out = sprintf("users_%s_%dnodes.dat", $type, $no_nodes); open IN, "< $in"; open OUT, "> $out"; $_ = <IN>; print OUT $_; $cnt = 0; while (<IN>) { $idx = $cnt % $no_nodes; s/node1/$nodes[$idx]/; print OUT $_; $cnt++; } close IN; close OUT; } #-------------------------------------------------