open(TXTIN,"ARGV[0]") || die "Cannot open the data file"; open(TXTOUT,">ARGV[1]") || die "Cannot open the formatted file"; #$itercnt=0 while() {#counting number of lines in input file $itercnt++ } for ($match=0;$match<$itercnt;$match++){ while(TXTIN){ chomp $_; $_ =~ s/yada/yadda/; print TXTOUT $_; }} #for (;$match=$itercnt;$match++){ # while(TXTIN){ # chomp $_; #$_ =~ s/different/regex here/; #print TXTOUT $_; #}} # getting stuck in infinite loop in here somewhere # so I haven't been able to see if it is working close(TXTIN); close(TXTOUT);