$module~;
}
sub make{
my$var = shift;
my@smn = split(/::/,$var);
my$name = pop(@smn);
my$foo = shift(@smn);
for(@files){
if($_=~/$foo.*$name\.pm/){
unless($modpath{$var}){$modpath{$var}=$_}
}
}
for(keys(%moddat)){
if($_ eq $var){
if($moddat{$_}==1){
$root=qq($var);
}
if($moddat{$_}==0){
$root=qq($var$markpm);
}
}
}
}
sub updatedat{
&makedat();
print header,start_html(-title=>"module list updated",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),h1('Updated'),p("Module list $dat updated with $modtotal modules"),hr,p(a({-href=>"$url"},'Reload'));
}
sub makedat{
&findmodules();
for(@foundmods){
my$var = $_;
my@smn = split(/::/,$var);
my$lname = pop(@smn);
my$foo = pop(@smn);
for(@files){
if($_=~/$foo.$lname\.pm/){
open(IT,"< $_") or next;
local $/ = undef;
my$it=;
close(IT) or die "Couldn't close module: $!";
if($it=~/=cut/ or /=head/ or /=item/){$rec{$var}=1}
else{$rec{$var}=0}
}
}
}
open(FILE,"> $dat") or die "$!";
print FILE qq~%moddat=(~;
for(sort { lc($a) cmp lc($b) } keys(%rec)){
print FILE qq~$_=>$rec{$_},~;
}
print FILE qq~);~;
close(FILE) or die "$!";
}
sub perlmod{
open(MU,"< $IN::pm") or die "$!";
local $/ = undef;
my$it=;
close(MU) or die "$!";
print header(-type=>'text/html'),start_html(-title=>"$IN::title",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),pre("$it");exit
}
sub perldoc{
$pod = $^T;
pod2html( "--htmlroot=$Bin",
"--infile=$_[0]",
"--outfile=$pod.html",
"--title=$_[1]",
);
open(IT,"< $pod.html") or die "$!";
local $/ = undef;
my$it=;
close(IT) or die "$!";
unlink "$pod.html";
print header(-type=>'text/html'),start_html(-title=>"$IN::title",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),p("$it");exit
}
sub check_type{
$file=$IN::filename;
if(-B $file){$type='binary'}
if(-T $file){$type='text/plain'}
if( $file=~/\.s?html?/i){$type='text/html'}
if($file=~/\.gif/i){$type='image/gif'}
if($file=~/.jpe?g?/i){$type='image/jpeg'}
}
sub view_file{
&check_type();
if($type=~/text/){
print header(-type=>"$type");
if($type=~/html/){ print start_html(-title=>"viewing $IN::filename",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink")}
open(FILE, "< $file") or die "$!";
local $/ = undef;
my$data = ;
close(FILE) or die "$!";
print $data;
}
if($type=~/image/){
print "Location: $file\n\n";
}
if($type=~/binary/){
print header,start_html(-title=>'Unsupported Binary',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),h1('Unsupported Binary'),p('Only GIF and JPEG binaries can be viewed.'),hr,("Ok");
}
exit;
}
sub edit_file{
&check_type();
if($type =~ /image/){
print header,start_html(-title=>'Feature not yet implemented',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),p,br,blockquote,p("Images can only be viewed");
exit;
}
if($type=~/binary/){
print header,start_html(-title=>'Unsupported Binary',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),h1('Unsupported Binary'),p('Only text files can be edited.'),hr("Ok");
exit;
}
$fs = -s $IN::filename;
open (FILE, "< $IN::filename") or die "$!";
local $/ = undef;
my$file = ;
close(FILE) or die "$!";
&encode_entities($file);
print header,start_html(-title=>"editing $IN::filename",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink");
my$fc = (length($IN::filename)+3);
($fL = $0) =~ s/$rurl$//o;
print<
HTML
print end_html;
exit;
}
sub stat_file{
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = stat $IN::filename;
print header,start_html(-title=>"stat $IN::filename",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink");
print<
results of stat $IN::filename
Field
Value
Device number of filesystem
$dev
Inode number
$ino
File mode (type and permissions)
$mode
Number of (hard) links to the file
$nlink
Numeric user ID of file's owner
$uid
Numeric group ID of file's owner
$gid
The device identifier (special files only)
$rdev
Total size of file, in bytes
$size
Last access time since the epoch
$atime
Last modify time since the epoch
$mtime
Inode change time (NOT creation time!) since the epoch
HTML
print end_html;
exit;
}
sub save_file{
&decode_entities($IN::filebody);
open (FILE, "> $IN::filename") or die "$!";
print FILE $IN::filebody;
close(FILE) or die "$!";
print header,start_html(-title=>'File Saved',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink"),h1('File Saved');
print qq~$IN::filename saved in $Binreturn~;
exit;
}
sub selfurls{
$url3 = url(-absolute=>1);
$url4 = url(-path_info=>1);
$url5 = url(-path_info=>1,-query=>1);
($url5 = $url5) =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/eg;
$url5 =~ tr/ /+/;
print header,start_html(-title=>'urls',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink");
print table({-border=>"$tbd",-bgcolor=>"$tc",-cellspacing=>'1',-cellpadding=>'4'},
Tr([td({-colspan=>'2',-bgcolor=>"$ta"},font({-size=>'+2'},b(tt('Full Path to this script by various methods'))))]),
Tr({-align=>'left',-bgcolor=>'dddddd'},[th('method').th('result')]),
Tr([td({-colspan=>'2',-bgcolor=>"$tb"},small(b('system paths')))]),
Tr([td(tt('$0')).td($0)]),
Tr([td(tt('FindBin($Bin)')).td($Bin)]),
Tr([td(tt('rel2abs($0)')).td(rel2abs($0))]),
Tr([td({-colspan=>'2',-bgcolor=>"$tb"},small(b('web paths')))]),
Tr([td("\$ENV{'SCRIPT_NAME'}").td($ENV{'SCRIPT_NAME'})]),
Tr([td(tt('$q->url()')).td($url)]),
Tr([td(tt('$q->url(-relative=>1)')).td($rurl)]),
Tr([td(tt('$q->url(-absolute=>1)')).td($url3)]),
Tr([td(tt('$q->url(-path_info=>1)')).td($url4)]),
Tr([td(tt('$q->url(-path_info=>1,-query=>1)')).td(small("$url5"))]),
Tr([td({-colspan=>'2',-bgcolor=>"$tb",-align=>'right'},"ok")]),
);
print end_html;
}
sub configure{
if($show_dir eq '1'){$checkp_dir=' checked'}
if($show_env eq '1'){$checkp_env=' checked'}
if($show_mod eq '1'){$checkp_mod=' checked'}
if($filter eq '1'){$checkp_filter=' checked'}
print header,start_html(-title=>'configure perlvars.pm',-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink");
print<
Display Preferences
If expand is checked the section
will be expanded by default, otherwise a check box and expand button
will appear near the section title.
section
expand
readdir
environment variables
installed modules
mark non-pod links with a
windowname for mod docs
filter modules
module dirs excluded from display
element
value
background color
text color
link color
visited link color
table shade light
table shade medium
table shade dark
table border
will overwrite current config with a fresh default.
HTML
exit;
}
sub info{
print header,start_html(-title=>"$rurl",-bgcolor=>"$bgc",-text=>"$btext",-link=>"$blink",-vlink=>"$bvlink");
print<
$rurl
perlvars is based on the concept of ScriptSolutions' great free unix-oriented
perl diver which lists useful environment variables and installed perl modules.
It was written so these functions could be expanded upon and enjoyed under Win32 as well as Unix systems.
Also in perlvars:
Listed modules are linked to their documentation. Either an html rendering of the pod
or raw module source code.
Control panel to customize preferences.
Automatic configuration file creation if either $cfg or $dat are not found in the current directory.
Directory browser that can view, edit and stat local files. Stat applies to all files,
text files with any extension can be viewed and edited, jpeg and gif images can be viewed.
Unfortunately, text files larger than a given browser software's textarea limit cannot be
edited.
Data file $cfg not detected in $path ~;
}
if(($init==1) or ($IN::go eq 'restore default')){
while(){$df .= $_} # read data
open (FILE, "> $cfg") or die "$!";
print FILE $df;
close(FILE) or die "$!";
print qq~
Created data file $path/$cfg~;
}
if($nodat==1){
print qq~
Data file $dat not detected in $path ~;
&makedat();
print qq~
Created data file $path/$dat~;
}
print<
Ready to reload or configure
HTML
exit
}
__END__
$bgc='#d0d0d0';
$btext='#000000';
$blink='#0000ff';
$bvlink='#6600aa';
$tbd='0';
$tc='#c0c0c0';
$tb='#b0b0b0';
$ta='#a0a0a0';
$show_dir='';
$show_env='1';
$show_mod='1';
$markpm='*';
$target='docs';
$filter='';
@filtered=qw(Tk);