in reply to search and replace with serialized answers
#!/usr/bin/perl use strict; open (INFILE, "$ARGV[0]"); my @lines = <INFILE>; close (INFILE); my $responses = 0; foreach (@lines) { if ($responses < $ARGV[1]) { $responses++ } else { $responses = 1; } chomp $lines[$_]; print $lines[$_] . $responses . "\n" }
input.txt
test test test test test test test test test test test
Called as:
{C} > test input.txt test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 test1 {C} > test input.txt 5 test1 test2 test3 test4 test5 test1 test2 test3 test4 test5 test1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: search and replace with serialized answers
by TheBigAmbulance (Acolyte) on May 01, 2009 at 19:23 UTC | |
by spx2 (Deacon) on May 01, 2009 at 19:43 UTC |