0
|
1 #! /usr/bin/perl -w
|
|
2
|
|
3 use strict;
|
|
4 use warnings;
|
|
5
|
|
6 # Removes the specified number of lines from the beginning of the file.
|
|
7 # remove_beginning.pl [input] [num_lines] [output]
|
|
8
|
|
9 die "Check arguments" unless @ARGV == 3;
|
|
10
|
|
11 my $inputfile = $ARGV[0];
|
|
12 my $num_lines = $ARGV[1];
|
|
13 my $outputfile = $ARGV[2];
|
|
14
|
|
15 my $curCount=0;
|
|
16
|
|
17 my $fhIn;
|
|
18 open ($fhIn, "< $inputfile") or die "Cannot open source file";
|
|
19
|
|
20 my $fhOut;
|
|
21 open ($fhOut, "> $outputfile");
|
|
22
|
|
23 while (<$fhIn>)
|
|
24 {
|
|
25 $curCount++;
|
|
26 if ($curCount<=$num_lines)
|
|
27 {
|
|
28 next;
|
|
29 }
|
|
30 print $fhOut $_;
|
|
31 }
|
|
32 close ($fhIn) or die "Cannot close source file";
|
|
33 close ($fhOut) or die "Cannot close output file";
|