The Ghost am Freitag, 2. Dezember 2005 19.30:
Hi,
In addition to John W. Krahn's good advices:
So far I did this:
#!/usr/bin/perl
use File::Find;
my $totalLines;
find(\wanted, '@directories');
sub wanted {
unless ($_=~m/.html|.mas|.pl|.txt$/i) {return 0;} #filter the
John Doe wrote:
The Ghost am Freitag, 2. Dezember 2005 19.30:
open FILE, $File::Find::name;
Always check if operations succeeded:
open (FILE, '', $File::Find::name)
or die couldn't open $File::Find::name: $!;
Thanks, don't know how I missed that. :-)
John
--
use
John Doe wrote:
The Ghost am Freitag, 2. Dezember 2005 19.30:
print $_: ;
my @lines=FILE;
and close opened files:
close FILE or die couldn't close $File::Find::name: $!;
print $#lines\n;
$totalLines+=$#lines; #wanted's value is ignored so we have to
do
John W. Krahn am Samstag, 3. Dezember 2005 15.27:
John Doe wrote:
The Ghost am Freitag, 2. Dezember 2005 19.30:
print $_: ;
my @lines=FILE;
and close opened files:
close FILE or die couldn't close $File::Find::name: $!;
print $#lines\n;
Jennifer Garner wrote:
$|=1;
Be careful with this one. The documentation for it makes it sound like
it's a good idea to set this but doing so turns buffering OFF, not ON.
Normally you leave this alone, even for pipes and sockets; Perl does the
right thing in almost every case.
See:
So far I did this:
#!/usr/bin/perl
use File::Find;
my $totalLines;
find(\wanted, '@directories');
sub wanted {
unless ($_=~m/.html|.mas|.pl|.txt$/i) {return 0;} #filter the kinds
of files you want
open FILE, $File::Find::name;
print $_: ;
my @lines=FILE;
The Ghost wrote:
So far I did this:
#!/usr/bin/perl
That should be followed by these two lines:
use warnings;
use strict;
use File::Find;
my $totalLines;
find(\wanted, '@directories');
Do you actually have a directory in the current directory named '@directories'?
sub wanted