You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Sam Carleton <sc...@activex-dev.com> on 2000/07/15 21:11:11 UTC
problems with code in "Writing Apache Modules with Perl and C"
I am new to perl and am trying to figure out how to get the navbar code
to work in the book "Writing Apache Modules with Perl and C". I have
trace it all the way down to the object that reads in the navbar config
file:
sub new {
my ($class,$conf_file, $r) = @_;
my (@c,%c);
my $fh = Apache::File->new($conf_file) || return;
while (<$fh>) {
chomp;
s/^\s+//; s/\s+$//; #fold leading and trailing whitespace
next if /^#/ || /^$/; # skip comments and empty lines
next unless my($url, $label) = /^(\S+)\s+(.+)/;
push @c, $url; # keep the url in an ordered array
$c{$url} = $label; # keep its label in a hash
$r->log_error("url = [$url], label = [$label]");
}
return bless {'urls' => \@c,
'labels' => \%c,
'modified' => (stat $conf_file)[9]}, $class;
}
What I would like to do is do a $r->log_error() right after "my($url,
$label) = /^(\S+)\s+(.+)/;", but that is at the end of a "next unless"
The bottom line is I would like to modify this code as to allow me to
see each line of the file I am reading in and to see what is being put
into the $url and $lable. Can someone help me out?
Sam