Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w print "Type in the name of the file you want to read: ", "\n" ; $count = 0 ; $filename =<STDIN> ; # reads in a file that I type in. chomp $filename ; # removes the newline after the filename open(FILE, $filename) || die "I can't read your file, it does not exi +st" ; while (defined ($line = <FILE>)) { if ($line =~ /word/) ## { $name = substr($word, 2, 11) ; print "the word number is: ", $name, "\n" ; + $count = 0 } elsif ($line !~ /#/) { $count++ ; } print "the number of text = ", $count, "\n" ; } close FILE ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Counting between the lines
by bobf (Monsignor) on Dec 14, 2004 at 07:38 UTC | |
|
Re: Counting between the lines
by gaal (Parson) on Dec 14, 2004 at 07:32 UTC | |
|
Re: Counting between the lines
by wfsp (Abbot) on Dec 14, 2004 at 07:24 UTC | |
by gaal (Parson) on Dec 14, 2004 at 07:35 UTC | |
|
Re: Counting between the lines
by ysth (Canon) on Dec 14, 2004 at 10:19 UTC |