Apache-Yaalr
view release on metacpan or search on metacpan
lib/Apache/Yaalr.pm view on Meta::CPAN
package Apache::Yaalr;
use 5.008008;
use strict;
use warnings;
use Carp qw(croak);
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw( @potential_confs );
our $VERSION = '0.03.3 ';
my (@potential_confs, @dirs);
my @mac = qw( /etc/apache /etc/apache2 /etc/httpd /usr/local/apache2 /Library/WebServer/ );
my @lin = qw( /etc/apache /etc/apache2/sites-avilable/ /etc/httpd /usr/local/apache2 /etc/apache-perl );
sub new {
my $package = shift;
return bless({}, $package);
}
sub os { # operating system best guess, we'll need this later
my $self = shift;
my $uname = `which uname`;
my @os;
if ($uname) {
push @os, `uname -a` or croak "Cannot execute uname -a";
} elsif ($^O) {
push @os, "$^O unknown";
} else {
push @os, "unknown unknown";
}
return @os;
}
# This is for getting info from a user supplied Apache2 config file
sub apache2_conf {
my ($self, $file) = @_;
croak("$file does not exist.") unless (-e $file);
croak("$file not readable.") unless (-r $file);
my ($str, $line, $format);
my (@formats, @format_string);
open FH, $file or croak "Cannot open configuration file: $file";
while (<FH>) {
if (/LogFormat/) {
push @formats, $_;
}
}
close FH;
# here we need to scoop up everything in sites-available
croak("Format not found\n") unless (($#formats) >= 0) ;
for (@formats) {
my @format_string = split / /, $_;
$format = pop @format_string;
$str = \@format_string;
}
return ($file, \$format, $str);
}
sub httpd_conf { # get LogFormat and type of log from user supplied httpd.conf file
my $self = shift;
my $file = shift;
croak("$file does not exist.") unless (-e $file);
# check the basename here to make sure we have a httpd.conf file
my ($str, $line, $log_type, $location, $format);
my ( @formats, @custom, @format_string,);
open FH, $file or croak "Cannot open configuration file: $file";
while (<FH>) {
if (/LogFormat/) {
push @formats, $_;
}
if (/CustomLog/) {
push @custom, $_;
}
}
close FH;
( run in 1.634 second using v1.01-cache-2.11-cpan-302cb4679cc )