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
Your first "while" statement is completely superflouos and is the cause of
your problem. You think your line number is 0 when you've actually read two
lines. You also need an increment statement for $lineNo.
hth
nate
-Original Message-
From: gnielson [mailto:[EMAIL PROTECTED]]
Sent: Mond
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