Since you know that the header is the top 11 lines (lines 0 .. 10), then you could do something like this (a simple script to display the desired lines, which just loops thru the lines starting with the 12th line):
#!/usr/bin/perl -w use strict; use LWP::Simple; my $stats_url = q{http://vspx27.stanford.edu/teamstats/team32.txt}; my $stats_txt = get($stats_url); my @lines = split(/\n/, $stats_txt); foreach my $i (11 .. $#lines) { print $lines[$i], qq{\n}; my @line_parts = split(/\s+/, $lines[$i]); # do something with the parts here, if desired.... }
Another way, if you're looping thru a text file, is to look at the value of $., which contains the current line number of the last file handle accessed, and just use something like next if ($. < 11); in your loop as you read thru the file. Example:
#!/usr/bin/perl -w use strict; my $data_file = qq{team32.txt}; open(DF, $data_file) or die(qq{Can't open $data_file for input: $!\n}); while (<DF>) { next if ($. < 11); chomp; print $_, qq{\n}; my @line_parts = split(/\s+/); # do something with the parts here, if desired.... } close(DF);
Hope that helps.
In reply to Re: i need to exclude data fetched from a .txt file
by atcroft
in thread i need to exclude data fetched from a .txt file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |