Kevin Zembower wrote:
>
> I feel so stupid, but I and a co-worker have been staring at this
> for two hours, with no progress.
I see that you got your problem fixed but just some comments on your
code. :-)
> I'm trying to run some perl scripts which came with the system Cacti.
> One is webhits.pl: centernet:/usr/local/httpd/htdocs/cacti8/scripts
> # cat webhits.pl
> #!/usr/local/bin/perl
>
> if ($ARGV[0] eq "") {
> $log_path = "/var/log/httpd/access_log";
> }else{
> $log_path = $ARGV[0];
> }
>
> $webhits = `wc -l $log_path`;
> $webhits =~ s/[\s]*([0-9]+).*//;
> print $1;
You are doing a lot of (unnecessary) work to get the number of lines in
the file.
my $webhits = do { no warnings 'numeric'; 0 + `wc -l $log_path` };
Or you can do it in perl without forking a separate process.
my $webhits = do {
open my $fh, $log_path or die "Cannot open $log_path: $!";
1 while <$fh>; $. };
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]