I do not get this with the code you pasted in? Normally taht would be a scoping issue from strict, but your scoping appears correct. With what your script does you need no other modules. The only thing that warned was the following:

Use of uninitialized value in join or string at ./temp.pl line 34, <> line 8.

And a couple more of the same message, but that is from your print not checking whether the variables originally had a value assigned, you should consider initializing them all to '' when you define them so that you can freely print them without checking for a value in eaech of them.

Try saving and running again??

http://danconia.org


leon probert wrote:
Hi,

I'm trying to parse a logfile using the example from the book 'Perl for Web Site Management.'I keep getting the errors 'Global symbol "$auth_user" requires explicit package name at ./log_report.plx line 21. The code I'm using is below.
Do I need to import a module? If anyone can point me in a direction to research this, I'd greatly appreciate it.

Thanks,

Len

#!/usr/bin/perl -w

# log_report.plx

# report on Web visitors

use strict;

my $log_format = 'common'; # 'common' or 'extended'

while (<>) {

my ($host, $ident_user, $auth_user, $date, $time,
$time_zone, $method, $url, $protocol, $status, $bytes,
$referer, $agent);

if ($log_format eq 'common') {

($host, $ident_user, $auth_user, $date, $time,
$time_zone, $method, $url, $protocol, $status, $bytes) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] "(\S+) (.+?) (\S+)" (\S+) (\S+)$/
or next;

} elsif ($log_format eq 'extended') {

($host, $ident_user, $auth_user, $date, $time,
$time_zone, $method, $url, $protocol, $status, $bytes,
$referer, $agent) =
/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] "(\S+) (.+?) (\S+)" (\S+) (\S+) "([^"]+)" "([^"]+)"$/
or next;
} else {
die "unrecognized log format '$log_format'";
}

print join "\n", $host, $ident_user, $auth_user, $date, $time,
$time_zone, $method, $url, $protocol, $status,
$bytes, $referer, $agent, "\n";
}







_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8. http://join.msn.com/?page=features/junkmail



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

Reply via email to