annotate remove_beginning.pl @ 0:d9b82504a321

Uploaded remove_beginning tarball.
author devteam
date Tue, 04 Dec 2012 11:02:31 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
1 #! /usr/bin/perl -w
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
2
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
3 use strict;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
4 use warnings;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
5
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
6 # Removes the specified number of lines from the beginning of the file.
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
7 # remove_beginning.pl [input] [num_lines] [output]
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
8
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
9 die "Check arguments" unless @ARGV == 3;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
10
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
11 my $inputfile = $ARGV[0];
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
12 my $num_lines = $ARGV[1];
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
13 my $outputfile = $ARGV[2];
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
14
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
15 my $curCount=0;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
16
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
17 my $fhIn;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
18 open ($fhIn, "< $inputfile") or die "Cannot open source file";
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
19
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
20 my $fhOut;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
21 open ($fhOut, "> $outputfile");
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
22
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
23 while (<$fhIn>)
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
24 {
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
25 $curCount++;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
26 if ($curCount<=$num_lines)
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
27 {
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
28 next;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
29 }
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
30 print $fhOut $_;
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
31 }
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
32 close ($fhIn) or die "Cannot close source file";
d9b82504a321 Uploaded remove_beginning tarball.
devteam
parents:
diff changeset
33 close ($fhOut) or die "Cannot close output file";