If I have this file:
Code:
A
Header
With
Unnecessary
Information
5 9 32 9
1 67 57 97
10 32 8 28
and I want this:
Code:
5 9 32 9
1 67 57 97
10 32 8 28
How would I do that with Perl's range operator?
If I use this script
Code:
#!/usr/bin/perl -w
$data = $ARGV[0];
open (IN, "$data") or die "can't open data:$!";
@datafile = <IN>; #Read the data file and store it in an array
close IN;
print @datafile[4 .. 6];
I get
Code:
Information
5 9 32 9
1 67 57 97
But if I want to print every row after (and including) line 4 what would the the second variable in the range operator? I know I could just use an absurdly large number that would extend beyond the length of my file:
Code:
print @datafile[4 .. 10000000];
That works. Or this works:
Code:
$num = @datafile;
print @datafile[4 .. $num];
But what would the the easiest, i.e. something to use for X in @datafile[4 ..
X]?