in reply to path is broken
work just as well?$line_count = `wc -l $filename`
Of course one could argue that you could just do the entire thing in Perl rather than using system calls; I might argue that, for instance. Here's a version of wc in Perl; you could extract the bits you need.
Or you could do something like this:
This would take care of your "space-in-filename" problem as well, since Perl won't care; it's only a problem when you pass it off to the shell like that.sub lines_in_file { my $f = shift; open FH, $f or die "Can't open $f: $!"; 1 while <FH>; $.; }
You can use this like:
my $line_count = lines_in_file($filename);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: path is broken
by a (Friar) on Dec 07, 2000 at 07:02 UTC |