http://www.perlmonks.org?node_id=432433


in reply to removing lines from a file

Another alternative:

Updated: to include the cut_out.txt file.

#!/usr/bin/perl -w use strict; use IO::All; my @cut_out = io("cut_out.txt")->slurp; my @lines = io('original.txt')->slurp; my $total_lines = 0; $total_lines += $_ foreach @cut_out; for (my $i = 0; $i <= ($total_lines - 1); $i++ ) { $i <= $cut_out[0] - 1 ? io("1.out.test.txt")->append($lines[$i]) : io("2.out.test.txt")->append($lines[$i]) }