Leon wrote:
> 
> ----- Original Message -----
> From: "Mark Mclogan" <[EMAIL PROTECTED]>
> > How I can know in that I number of line finds a word in a text file?.
> > For example, a file "file.txt" contains the following list:
> >
> > Chocolate
> > Cake
> > Cheese
> > Apple
> > orange
> > melon
> > lemon
> >
> > How I can know in that line number is the Apple word?
> 
> open FILE, 'file.txt' or die "$!\n";
> while (<FILE>){
>         chomp;
>         my $count++;

$count is lexically scoped to the while loop so it will always have a
value of one.

>         print "Apple is found in line number $count\n" if (/Apple/);
> };
> close FILE;


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to