Glen Lee Edwards wrote:
> open(FD,"$file") || die "Can not open $file";
> while() {
>
> while ($line = )
> {
> print "lineNo is $. and text is $text\n";
>
> next if ($. < $text);
> print $line;
> }
> }
> close FD;
I don't t
Actually this will work better. You have a double while loop. It may
work, don't know, never done it that way.
open(FD,"$file") || die "Can not open $file";
while() {
print "lineNo is $. and text is $text\n";
next if ($. < $text);
print $line;
}
close FD;
$. is a special v
Try:
open(FD,"$file") || die "Can not open $file";
while() {
while ($line = )
{
print "lineNo is $. and text is $text\n";
next if ($. < $text);
print $line;
}
}
close FD;
$. is a special variable containing the current in
ROTECTED]]
Sent: Monday, November 22, 1999 8:34 AM
To: Redhat list
Subject: Help with perl next if loop problem
I am trying to write a perl script that will read a number from a file,
use that as a counter, and only print out lines above that counter number.
So if the number is 5 and the file is 10
I can't make heads or tail of your version, bu this works for me.
#line.pl
#!/usr/local/bin/perl
open (FILE, $ARGV[0] ) or die "$!\n";
my $count = ;
chomp($count);
$line = 1;
while ( ) {
print if $line++ > $count;
}
#line.txt
3
line1
line2
line3
line4
line5
line6
line7
[cgalpin@pooh perl
I am trying to write a perl script that will read a number from a file,
use that as a counter, and only print out lines above that counter number.
So if the number is 5 and the file is 10 lines, only the last 5 lines
would be printed.
The problem is when it prints out it misses one line, so inste