[11301] in Perl-Users-Digest
Perl-Users Digest, Issue: 4901 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 15 18:07:30 1999
Date: Mon, 15 Feb 99 15:01:53 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 15 Feb 1999 Volume: 8 Number: 4901
Today's topics:
SRC: pmdirs - print the perl module path, newline separ <tchrist@mox.perl.com>
SRC: pmeth - show a class's methods <tchrist@mox.perl.com>
SRC: pmexp - show a module's exports <tchrist@mox.perl.com>
SRC: pmfunc - show a function <tchrist@mox.perl.com>
SRC: pminst - find modules whose names match this patte <tchrist@mox.perl.com>
SRC: pmload - show what files a module loads <tchrist@mox.perl.com>
SRC: pmls - show date stamp of module <tchrist@mox.perl.com>
SRC: pmpath - show path to a perl module <tchrist@mox.perl.com>
SRC: pmvers - print out a module's version <tchrist@mox.perl.com>
SRC: podgrep -- grep in pod sections only <tchrist@mox.perl.com>
SRC: podpath - print the path to the pod <tchrist@mox.perl.com>
SRC: pods - print out all pod paths <tchrist@mox.perl.com>
SRC: podtoc -- show outline of pods <tchrist@mox.perl.com>
SRC: sitepods - print out the paths to the modules <tchrist@mox.perl.com>
SRC: stdpods - print out the paths to the modules that <tchrist@mox.perl.com>
Re: String Compare (Karlon West)
temp file (Daqing Chu)
Re: temp file (Sam Holden)
trying to get all the data from an array, assigned from jouell@zdnetmail.com
Re: V-day Perl Poetry <bmb@ginger.libs.uga.edu>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Feb 1999 15:05:16 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmdirs - print the perl module path, newline separated
Message-Id: <36c89a1c@csnews>
#!/usr/bin/env perl
# pmdirs -- print the perl module path, newline separated
# tchrist@perl.com
BEGIN { $^W = 1 }
for (@INC) {
print $_, "\n";
}
__END__
=head1 NAME
pmdirs - print out module directories
=head1 DESCRIPTION
This just prints out the current @INC path, one directory per line.
This is for people who don't want to parse through C<perl -V> output or
hack up their own calls to C<perl -e>.
=head1 EXAMPLES
$ pmdirs
/home/tchrist/perllib/i686-linux
/home/tchrist/perllib
/usr/local/devperl/lib/5.00554/i686-linux
/usr/local/devperl/lib/5.00554
/usr/local/devperl/lib/site_perl/5.00554/i686-linux
/usr/local/devperl/lib/site_perl/5.00554
.
This also works for alternate version of Perl:
$ filsperl -S pmdirs
/home/tchrist/perllib
/usr/local/filsperl/lib/5.00554/i686-linux-thread
/usr/local/filsperl/lib/5.00554
/usr/local/filsperl/lib/site_perl/5.00554/i686-linux-thread
/usr/local/filsperl/lib/site_perl/5.00554
.
=head1 SEE ALSO
perlrun(1), perlvar(1), lib(3)
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Mathematics: That branch of Human Thought which takes a finite set of trivial
axioms and maps them to a countably infinite set of unintuitive theorems.
------------------------------
Date: 15 Feb 1999 15:02:37 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmeth - show a class's methods
Message-Id: <36c8997d@csnews>
#!/usr/bin/env perl
# pmeth -- show a class's methods
# tchrist@perl.com
BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module\n" unless @ARGV == 1 }
$errors = 0;
%got_def = ();
show_methods($ARGV[0]);
show_methods("UNIVERSAL", $ARGV[0]);
sub show_methods {
my $module = shift;
my @indirect = @_;
my @baseclasses = @indirect[ 0 .. ($#indirect-1) ];
eval "require $module";
if ($@) {
$@ =~ s/at \(eval.*$//;
warn "$0: $@";
$errors++;
return;
}
foreach $name ( sort keys %{ $module . "::" } ) {
if (defined &{ $module . "::" . $name } ) {
print "[overridden] " if $got_def{$name}++;
if (@indirect) {
print join(" via ", $name, $module, @baseclasses), "\n";
} else {
print "$name\n";
}
}
}
if (my @parents = @{ $module . "::ISA" } ) {
foreach $ancestor (@parents) {
show_methods($ancestor, $module, @indirect);
}
}
}
exit ($errors != 0);
__END__
=head1 NAME
pmeth - show a Perl class's methods
=head1 DESCRIPTION
Given a class name, print out all methods available to that class.
It does this by loading in the class module, and walking its
symbol table and those of its ancestor classes. A regular method
call shows up simply:
$ pmeth IO::Socket | grep '^con'
confess
configure
connect
connected
But one that came from else where is noted with one or
more "via" notations:
DESTROY via IO::Handle
export via Exporter via IO::Handle
A base-class method that is unavailable due to being hidden by a close
derived-class method by the same name (but accessible via SUPER::)
is indicated by a leading "[overridden]" before it:
[overridden] new via IO::Handle
=head1 EXAMPLES
$ pmeth IO::Socket
AF_INET
AF_UNIX
INADDR_ANY
INADDR_BROADCAST
INADDR_LOOPBACK
INADDR_NONE
SOCK_DGRAM
SOCK_RAW
SOCK_STREAM
accept
bind
carp
confess
configure
connect
connected
croak
getsockopt
import
inet_aton
inet_ntoa
listen
new
pack_sockaddr_in
pack_sockaddr_un
peername
protocol
recv
register_domain
send
setsockopt
shutdown
sockaddr_in
sockaddr_un
sockdomain
socket
socketpair
sockname
sockopt
socktype
timeout
unpack_sockaddr_in
unpack_sockaddr_un
DESTROY via IO::Handle
SEEK_CUR via IO::Handle
SEEK_END via IO::Handle
SEEK_SET via IO::Handle
_IOFBF via IO::Handle
_IOLBF via IO::Handle
_IONBF via IO::Handle
_open_mode_string via IO::Handle
autoflush via IO::Handle
blocking via IO::Handle
[overridden] carp via IO::Handle
clearerr via IO::Handle
close via IO::Handle
[overridden] confess via IO::Handle
constant via IO::Handle
[overridden] croak via IO::Handle
eof via IO::Handle
error via IO::Handle
fcntl via IO::Handle
fdopen via IO::Handle
fileno via IO::Handle
flush via IO::Handle
format_formfeed via IO::Handle
format_line_break_characters via IO::Handle
format_lines_left via IO::Handle
format_lines_per_page via IO::Handle
format_name via IO::Handle
format_page_number via IO::Handle
format_top_name via IO::Handle
format_write via IO::Handle
formline via IO::Handle
gensym via IO::Handle
getc via IO::Handle
getline via IO::Handle
getlines via IO::Handle
gets via IO::Handle
input_line_number via IO::Handle
input_record_separator via IO::Handle
ioctl via IO::Handle
[overridden] new via IO::Handle
new_from_fd via IO::Handle
opened via IO::Handle
output_field_separator via IO::Handle
output_record_separator via IO::Handle
print via IO::Handle
printf via IO::Handle
printflush via IO::Handle
qualify via IO::Handle
qualify_to_ref via IO::Handle
read via IO::Handle
setbuf via IO::Handle
setvbuf via IO::Handle
stat via IO::Handle
sync via IO::Handle
sysread via IO::Handle
syswrite via IO::Handle
truncate via IO::Handle
ungensym via IO::Handle
ungetc via IO::Handle
untaint via IO::Handle
write via IO::Handle
_push_tags via Exporter via IO::Handle
export via Exporter via IO::Handle
export_fail via Exporter via IO::Handle
export_ok_tags via Exporter via IO::Handle
export_tags via Exporter via IO::Handle
export_to_level via Exporter via IO::Handle
[overridden] import via Exporter via IO::Handle
require_version via Exporter via IO::Handle
VERSION via UNIVERSAL
can via UNIVERSAL
[overridden] import via UNIVERSAL
isa via UNIVERSAL
=head1 NOTE
Perl makes no distinction between functions, procedures, and methods,
nor whether they are public or nominally private, nor whether a method
is nominally a class method, an object method, or both. They all show up
as subs in the package namespace. So if your class says C<use Carp>, you
just polluted your namespace with things like croak() and confess(), which
will appear to be available as method calls on objects of your class.
=head1 SEE ALSO
perltoot(1), perlobj(1)
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
"They'll get my perl when they pry it from my cold, dead /usr/local/bin."
Randy Futor in <1992Sep13.175035.5623@tc.fluke.COM>
------------------------------
Date: 15 Feb 1999 15:03:06 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmexp - show a module's exports
Message-Id: <36c8999a@csnews>
#!/usr/bin/env perl
# pmexp -- show a module's exports
# tchrist@perl.com
BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module ...\n" unless @ARGV }
$errors = 0;
for $module (@ARGV) {
eval "require $module";
if ($@) {
$@ =~ s/at \(eval.*$//;
warn "$0: $@";
$errors++;
next;
}
if (@list = @{ $module . "::EXPORT" } ) {
print "$module automatically exports ",
commify_series(@list), "\n";
}
if (@list = @{ $module . "::EXPORT_OK" } ) {
print "$module optionally exports ",
commify_series(@list), "\n";
}
if (%table = %{ $module . "::EXPORT_TAGS" } ) {
for $tag (sort keys %table) {
print "$module export tag `$tag' includes ", commify_series(@{$table{$tag}}), "\n";
}
}
}
exit($errors != 0);
sub commify_series {
(@_ == 0) ? '' :
(@_ == 1) ? $_[0] :
(@_ == 2) ? join(" and ", @_) :
join(", ", @_[0 .. ($#_-1)], "and $_[-1]");
}
__END__
=head1 NAME
pmexp - show a module's exports
=head1 DESCRIPTION
Given a module name, this program identifies which symbols are
automatically exported (in that package's @EXPORT), those which are
optionally exported (in that package's @EXPORT_OK), and also lists out
the import groups (in that package's %EXPORT_TAGS hash).
=head1 EXAMPLES
$ pmexp Text::ParseWords
Text::ParseWords automatically exports shellwords, quotewords, nested_quotewords, and parse_line
Text::ParseWords optionally exports old_shellwords
$ pmexp Text::Wrap
Text::Wrap automatically exports wrap and fill
Text::Wrap optionally exports $columns, $break, and $huge
$ pmexp Fcntl
Fcntl automatically exports FD_CLOEXEC, F_DUPFD, F_EXLCK, F_GETFD, F_GETFL, F_GETLK, F_GETLK64, F_GETOWN, F_POSIX, F_RDLCK, F_SETFD, F_SETFL, F_SETLK, F_SETLK64, F_SETLKW, F_SETLKW64, F_SETOWN, F_SHLCK, F_UNLCK, F_WRLCK, O_ACCMODE, O_APPEND, O_ASYNC, O_BINARY, O_CREAT, O_DEFER, O_DSYNC, O_EXCL, O_EXLOCK, O_LARGEFILE, O_NDELAY, O_NOCTTY, O_NONBLOCK, O_RDONLY, O_RDWR, O_RSYNC, O_SHLOCK, O_SYNC, O_TEXT, O_TRUNC, and O_WRONLY
Fcntl optionally exports FAPPEND, FASYNC, FCREAT, FDEFER, FEXCL, FNDELAY, FNONBLOCK, FSYNC, FTRUNC, LOCK_EX, LOCK_NB, LOCK_SH, and LOCK_UN
Fcntl export tag `Fcompat' includes FAPPEND, FASYNC, FCREAT, FDEFER, FEXCL, FNDELAY, FNONBLOCK, FSYNC, and FTRUNC
Fcntl export tag `flock' includes LOCK_SH, LOCK_EX, LOCK_NB, and LOCK_UN
=head1 BUGS
The output formatting should be nicer, perhaps using
C<format> and C<write>.
=head1 SEE ALSO
pmeth(1), perlmod(1), Exporter(3).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Remember though that
THERE IS NO GENERAL RULE FOR CONVERTING A LIST INTO A SCALAR.
--Larry Wall in the perl man page
------------------------------
Date: 15 Feb 1999 15:05:42 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmfunc - show a function
Message-Id: <36c89a36@csnews>
#!/usr/bin/env perl
# pmfunc -- show a function
# tchrist@perl.com
BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module ...\n" unless @ARGV }
use FindBin qw($Bin);
$errors = 0;
for $arg (@ARGV) {
my($module, $function) = $arg =~ /(\w.*)::(\w+)$/;
$file = `$^X $Bin/pmpath $module`;
if ($?) {
$errors++;
next;
}
chomp $file;
system $^X, '-ne',
'$ok++,print if /^sub\s+' . $function . '\b/ .. /^}\s*$/;'
. ' END { $? = ($ok == 0) }',
$file;
$errors++ if $?;
}
exit ($errors != 0);
__END__
=head1 NAME
pmfunc - cat out a function from a module
=head1 DESCRIPTION
Given a fully-qualified function, this program opens
up the file and attempts to cat out the source for
that function.
=head1 EXAMPLES
$ pmfunc Cwd::getcwd
sub getcwd
{
abs_path('.');
}
=head1 RESTRICTIONS
Only subroutines that are defined in the normal fashion are seen, since
a simple pattern-match is what does the extraction. Those loaded other
ways, such as via AUTOLOAD, typeglob aliasing, or in an C<eval>, will
all necessarily be missed.
This is mostly here for people who are too lazy to type
sed '/^sub getcwd/,/}/p' `pmpath Cwd`
or
perl -ne 'print if /^sub\s+getcwd\b/ .. /}/' `pmpath Cwd`
=head1 RESTRICTIONS
=head1 SEE ALSO
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Data structures, not algorithms, are central to programming. --Rob Pike
------------------------------
Date: 15 Feb 1999 15:03:36 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pminst - find modules whose names match this pattern
Message-Id: <36c899b8@csnews>
#!/usr/bin/env perl
# pminst -- find modules whose names match this pattern
# tchrist@perl.com
BEGIN { $^W = 1 }
use Getopt::Std qw(getopts);
use File::Find;
getopts('ls') || die "bad usage";
if (@ARGV == 0) {
@ARGV = ('.');
}
die "usage: $0 [-l] [-s] pattern\n" unless @ARGV == 1;
$pattern = shift();
$pattern =~ s,::,/,g;
no lib '.';
use vars qw($opt_l $opt_s);
for $startdir (@INC) {
find(\&wanted, $startdir);
}
sub wanted {
if (-d && /^[a-z]/) {
# this is so we don't go down site_perl etc too early
$File::Find::prune = 1;
return;
}
return unless /\.pm$/;
local $_ = $File::Find::name;
($tmpname = $_) =~ s{^\Q$startdir/}{};
return unless $tmpname =~ /$pattern/o;
if ($opt_l) {
s{^(\Q$startdir\E)/}{$1 } if $opt_s;
}
else {
s{^\Q$startdir/}{};
s/\.pm$//;
s{/}{::}g;
print "$startdir " if $opt_s;
}
print $_, "\n";
}
__END__
=head1 NAME
pminst - find modules whose names match this pattern
=head1 SYNOPSIS
pminst [B<-s>] [B<-l>] [I<pattern>]
=head1 DESCRIPTION
Without argumnets, show the names of all installed modules. Given a
pattern, show all module names that match it. The B<-l> flag will show
the full pathname. The B<-s> flag will separate the base directory from
@INC from the module portion itself.
=head1 EXAMPLES
$ pminst
(lists all installed modules)
$ pminst Carp
CGI::Carp
Carp
$ pminst ^IO::
IO::Socket::INET
IO::Socket::UNIX
IO::Select
IO::Socket
IO::Poll
IO::Handle
IO::Pipe
IO::Seekable
IO::Dir
IO::File
$ pminst '(?i)io'
IO::Socket::INET
IO::Socket::UNIX
IO::Select
IO::Socket
IO::Poll
IO::Handle
IO::Pipe
IO::Seekable
IO::Dir
IO::File
IO
Pod::Functions
The -s flag provides output with the directory separated
by a space:
$ pminst -s | sort +1
(lists all modules, sorted by name, but with where they
came from)
$ oldperl -S pminst -s IO
/usr/lib/perl5/i386-linux/5.00404 IO::File
/usr/lib/perl5/i386-linux/5.00404 IO::Handle
/usr/lib/perl5/i386-linux/5.00404 IO::Pipe
/usr/lib/perl5/i386-linux/5.00404 IO::Seekable
/usr/lib/perl5/i386-linux/5.00404 IO::Select
/usr/lib/perl5/i386-linux/5.00404 IO::Socket
/usr/lib/perl5/i386-linux/5.00404 IO
/usr/lib/perl5/site_perl LWP::IO
/usr/lib/perl5/site_perl LWP::TkIO
/usr/lib/perl5/site_perl Tk::HTML::IO
/usr/lib/perl5/site_perl Tk::IO
/usr/lib/perl5/site_perl IO::Stringy
/usr/lib/perl5/site_perl IO::Wrap
/usr/lib/perl5/site_perl IO::ScalarArray
/usr/lib/perl5/site_perl IO::Scalar
/usr/lib/perl5/site_perl IO::Lines
/usr/lib/perl5/site_perl IO::WrapTie
/usr/lib/perl5/site_perl IO::AtomicFile
The -l flag gives full paths:
$ filsperl -S pminst -l Thread
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Queue.pm
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Semaphore.pm
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Signal.pm
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread/Specific.pm
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Real programmers can write assembly code in any language. :-)
--Larry Wall in <8571@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 15 Feb 1999 15:06:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmload - show what files a module loads
Message-Id: <36c89a53@csnews>
#!/usr/bin/env perl
# pmload -- show what files a module loads
# tchrist@perl.com
BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module\n" unless @ARGV == 1 }
%seen = %INC;
$module = shift;
eval "require $module";
if ($@) {
$@ =~ s/at \(eval.*$//;
die "$0: $@";
}
for $path (values %INC) {
print "$path\n" unless $seen{$path};
}
__END__
=head1 NAME
pmload - show what files a given module loads at compile time
=head1 DESCRIPTION
Given an argument of a module name, show all the files
that are loaded directly or indirectly when the module
is used at compile-time.
=head1 EXAMPLES
$ pmload IO::Handle
/usr/local/devperl/lib/5.00554/Exporter.pm
/usr/local/devperl/lib/5.00554/Carp.pm
/usr/local/devperl/lib/5.00554/strict.pm
/usr/local/devperl/lib/5.00554/vars.pm
/usr/local/devperl/lib/5.00554/i686-linux/DynaLoader.pm
/usr/local/devperl/lib/5.00554/i686-linux/IO/Handle.pm
/usr/local/devperl/lib/5.00554/Symbol.pm
/usr/local/devperl/lib/5.00554/i686-linux/IO/File.pm
/usr/local/devperl/lib/5.00554/SelectSaver.pm
/usr/local/devperl/lib/5.00554/i686-linux/Fcntl.pm
/usr/local/devperl/lib/5.00554/AutoLoader.pm
/usr/local/devperl/lib/5.00554/i686-linux/IO.pm
/usr/local/devperl/lib/5.00554/i686-linux/IO/Seekable.pm
$ cat `pmload IO::Socket` | wc -l
4015
$ oldperl -S pmload Tk
/usr/lib/perl5/site_perl/Tk/Pretty.pm
/usr/lib/perl5/Symbol.pm
/usr/lib/perl5/site_perl/Tk/Frame.pm
/usr/lib/perl5/site_perl/Tk/Toplevel.pm
/usr/lib/perl5/strict.pm
/usr/lib/perl5/Exporter.pm
/usr/lib/perl5/vars.pm
/usr/lib/perl5/site_perl/auto/Tk/Wm/autosplit.ix
/usr/lib/perl5/site_perl/auto/Tk/Widget/autosplit.ix
/usr/lib/perl5/site_perl/Tk.pm
/usr/lib/perl5/i386-linux/5.00404/DynaLoader.pm
/usr/lib/perl5/site_perl/auto/Tk/Frame/autosplit.ix
/usr/lib/perl5/site_perl/auto/Tk/Toplevel/autosplit.ix
/usr/lib/perl5/Carp.pm
/usr/lib/perl5/site_perl/auto/Tk/autosplit.ix
/usr/lib/perl5/site_perl/Tk/CmdLine.pm
/usr/lib/perl5/site_perl/Tk/MainWindow.pm
/usr/lib/perl5/site_perl/Tk/Submethods.pm
/usr/lib/perl5/site_perl/Tk/Configure.pm
/usr/lib/perl5/AutoLoader.pm
/usr/lib/perl5/site_perl/Tk/Derived.pm
/usr/lib/perl5/site_perl/Tk/Image.pm
/usr/lib/perl5/site_perl/Tk/Wm.pm
/usr/lib/perl5/site_perl/Tk/Widget.pm
=head1 NOTE
If the programmers used a delayed C<require>, those files won't show up.
Furthermore, this doesn't show all possible files that get opened,
just those that those up in %INC. Most systems have a way to trace
system calls. You can use this to find the real answer. First, get a
baseline with no modules loaded.
$ strace perl -e 1 2>&1 | perl -nle '/^open\("(.*?)".* = [^-]/ && print $1'
/etc/ld.so.cache
/lib/libnsl.so.1
/lib/libdb.so.2
/lib/libdl.so.2
/lib/libm.so.6
/lib/libc.so.6
/lib/libcrypt.so.1
/dev/null
$ strace perl -e 1 2>&1 | grep -c '^open.*= [^-]'
8
Now add module loads and see what you get:
$ strace perl -MIO::Socket -e 1 2>&1 | grep -c '^open.*= [^-]'
24
$ strace perl -MTk -e 1 2>&1 | grep -c '^open.*= [^-]'
35
=head1 SEE ALSO
Devel::Loaded, plxload(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
"A well-written program is its own heaven;
a poorly-written program is its own hell."
------------------------------
Date: 15 Feb 1999 15:06:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmls - show date stamp of module
Message-Id: <36c89a74@csnews>
#!/usr/bin/env perl
# pmls -- show date stamp of module
# tchrist@perl.com
BEGIN { $^W = 1 }
use FindBin qw($Bin);
unless (@ARGV) {
die "usage: $0 module ...\n";
}
for $module (@ARGV) {
system "ls -l " . `$^X $Bin/pmpath $module`;
}
__END__
=head1 NAME
pmls - long list the module path
=head1 DESCRIPTION
This is mostly here for people too lazy to type
$ ls -l `pmpath CGI`
=head1 EXAMPLES
$ pmls CGI
-r--r--r-- 1 root root 190901 Dec 6 03:19
/usr/local/devperl/lib/5.00554/CGI.pm
$ oldperl -S pmls CGI
-r--r--r-- 1 root root 186637 Sep 10 00:18
/usr/lib/perl5/CGI.pm
=head1 SEE ALSO
pmpath(1)
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
"Just because you're into control doesn't mean you're in control."
--Larry Wall
------------------------------
Date: 15 Feb 1999 15:07:04 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmpath - show path to a perl module
Message-Id: <36c89a88@csnews>
#!/usr/bin/env perl
# pmpath -- show path to a perl module
# tchrist@perl.com
BEGIN { $^W = 1 }
$errors = 0;
for $module (@ARGV) {
eval "require $module";
if ($@) {
$@ =~ s/at \(eval.*$//;
warn "$0: $@";
$errors++;
next;
}
for ($shortpath = $module) {
s{::}{/}g;
s/$/.pm/;
}
# print "$module is in " if @ARGV > 1;
if (defined($fullpath = $INC{$shortpath})) {
print "$fullpath\n";
}
else {
$errors++;
warn "$0: path unavailable in %INC\n";
}
}
exit ($errors != 0);
__END__
=head1 NAME
pmpath - show full path to a perl module
=head1 SYNOPSIS
pmpath module ...
=head1 DESCRIPTION
For each module name given as an argument, produces its full path on
the standard output, one per line.
=head1 EXAMPLES
$ pmpath CGI
/usr/local/devperl/lib/5.00554/CGI.pm
$ filsperl -S pmpath IO::Socket CGI::Carp
/usr/local/filsperl/lib/5.00554/i686-linux-thread/IO/Socket.pm
/usr/local/filsperl/lib/5.00554/CGI/Carp.pm
$ oldperl -S pmpath CGI CGI::Imagemap
/usr/lib/perl5/CGI.pm
/usr/lib/perl5/site_perl/CGI/Imagemap.pm
=head1 SEE ALSO
pmdesc(1),
pmvers(1),
pmcat(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Doing linear scans over an associative array is like trying to club someone
to death with a loaded Uzi. --Larry Wall
------------------------------
Date: 15 Feb 1999 15:07:26 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmvers - print out a module's version
Message-Id: <36c89a9e@csnews>
#!/usr/bin/env perl
# pmvers -- print out a module's version, if findable
# tchrist@perl.com
BEGIN { $^W = 1 }
$errors = 0;
for $module (@ARGV) {
eval "require $module";
if ($@) {
$@ =~ s/at \(eval.*$//;
warn "$0: $@";
$errors++;
next;
}
print "$module: " if @ARGV > 1;
if (defined($version = $module->VERSION())) {
print "$version\n";
}
else {
$errors++;
if (@ARGV > 1) {
print "unknown version\n";
}
else {
warn "$0: unknown version for module `$module'\n";
}
}
}
exit ($errors != 0);
__END__
=head1 NAME
pmvers - print out a module's version
=head1 DESCRIPTION
Given one or more module names, show the version number if present.
If more than one argument is given, the name of the module will also
be printed. Not all modules define version numbers, however.
=head EXAMPLES
$ pmvers CGI
2.46
$ pmvers IO::Socket Text::Parsewords
IO::Socket: 1.25
Text::ParseWords: 3.1
$ oldperl -S pmvers CGI
2.42
$ filsperl -S pmvers CGI
2.46
$ pmvers Devel::Loaded
pmvers: unknown version for module `Devel::Loaded'
h=ead1 SEE ALSO
pmdesc(1),
pmpath(1),
pmcat(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
: I've tried (in vi) "g/[a-z]\n[a-z]/s//_/"...but that doesn't
: cut it. Any ideas? (I take it that it may be a two-pass sort of solution).
In the first pass, install perl. :-) Larry Wall <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 15 Feb 1999 15:14:40 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: podgrep -- grep in pod sections only
Message-Id: <36c89c50@csnews>
#!/usr/bin/env perl
# podgrep -- grep in pod sections only
# tchrist@perl.com
use Getopt::Std qw(getopts);
getopts("fhpi")
|| die "usage: $0 [-i] [-f] [-h] [-p] pattern [podfiles ...]";
$/ = '';
$only_header = $opt_h;
$orig_pattern = $pattern = shift;
$pattern = '^=.*' . $pattern if $only_header;
$pattern .= '(?i)' if $opt_i;
if ($opt_p) {
unless ($pager = $ENV{PAGER}) {
require Config;
$pager = $Config::Config{"pager"} || "more";
}
}
if ($opt_f) {
if ($opt_p) {
open(STDOUT, "| pod2text | $pager '+/$orig_pattern'");
} else {
open(STDOUT, "| pod2text");
}
}
elsif ($opt_p) {
open(STDOUT, "| $pager '+/$orig_pattern'");
}
($file, $chunk) = ('-', 0);
while (<>) {
if ($inpod && /^=cut/) {
$inmatch = $inpod = 0;
next;
}
if (! $inpod && /^=(?!cut)\w+/) {
$inpod = 1;
}
if ($inmatch && /^=\w+/) {
$inmatch = 0;
}
if ($inpod && !$inmatch && /$pattern/o) {
print "=head1 $ARGV chunk $.\n\n"
unless $file eq $ARGV && $chunk+1 == $.;
($file, $chunk) = ($ARGV, $.);
print;
$inmatch = 1 if $only_header;
next;
}
print if $inmatch;
} continue {
if (eof) {
$inmatch = $inpod = 0;
($file, $chunk) = ('-', 0);
close ARGV;
}
}
close STDOUT;
__END__
=head1 NAME
podgrep - grep in pod sections only
=head1 SYNOPSIS
podgrep [B<-i>] [B<-p>] [B<-f>] [B<-h>] I<pattern> [ I<files> ... ]
=head1 DESCRIPTION
This program searches each paragraph in a pod document and prints each
paragraph that matches the supplied pattern. This pod may be mixed with
program code, such as in a module.
Options are:
=over 4
=item -i
means case insensitive match
=item -p
means page output though the user's pager. The pager will be primed
with an argument to search for the string. This highlights the result.
=item -f
means format output though the I<pod2text> program.
=item -h
means check for matches in pod C<=head> and C<=item> headers alone,
and to keep printing podagraphs until the next header is found.
=back
=head1 EXAMPLES
$ podgrep mail `pmpath CGI`
(prints out podagraphs from the CGI.pm manpage that mention mail)
$ podgrep -i destructor `sitepods`
(prints out podagraphs that mention destructors in the
site-installed pods)
$ podgrep -i 'type.?glob' `stdpods`
(prints out podagraphs that mention typeglob in the
standard pods)
$ podgrep -hpfi "lock" `faqpods`
(prints out all podagraphs with "lock" in the headers
case-insensitively, then then formats these with pod2text, then
shows them in the pager with matches high-lighted)
$ podgrep -fh seek `podpath perlfunc`
(prints out and formats podagraphs from the standard perlfunc manpage
whose headers or items contain "seek".)
=head1 SEE ALSO
faqpods(1),
pfcat(1),
pmpath(1),
pod2text(1),
podpath(1),
sitepods(1),
stdpods(1),
and
tcgrep(1).
=head1 NOTE
For a pager, the author likes these environment settings (in the login
startup, of course):
$ENV{PAGER} = "less";
$ENV{LESS} = "MQeicsnf";
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Chip Salzenberg sent me a complete patch to add System V IPC (msg, sem and
shm calls), so I added them. If that bothers you, you can always undefine
them in config.sh. :-) --Larry Wall in <9384@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 15 Feb 1999 15:12:31 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: podpath - print the path to the pod
Message-Id: <36c89bcf@csnews>
#!/usr/bin/env perl
# podpath - print the path to the pod
for (@ARGV) {
if ( /^perl/ ) {
system("$^X -S stdpods | grep $_");
} else {
system("$^X -S pmpath $_");
}
}
__END__
=head1 NAME
podpath - print the path to the pod
=head1 DESCRIPTION
This is just a front-end that calls either I<stdpods>
or I<pmpath> depending on what it looks like. It works
on both regular the standard podpages and the module ones.
=head1 EXAMPLES
$ podpath Cwd
/usr/local/devperl/lib/5.00554/Cwd.pm
It works with alternate installations, too:
$ devperl -S podpath perlfunc
/usr/local/devperl/lib/5.00554/pod/perlfunc.pod
$ oldperl -S podpath IO::Handle
/usr/lib/perl5/i386-linux/5.00404/IO/Handle.pm
$ filsperl -S podpath Thread
/usr/local/filsperl/lib/5.00554/i686-linux-thread/Thread.pm
=head1 SEE ALSO
stdpods(1),
pmpath(1),
perlmodlib(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
echo "I can't find the O_* constant definitions! You got problems."
--The Configure script from the perl distribution
------------------------------
Date: 15 Feb 1999 15:14:20 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pods - print out all pod paths
Message-Id: <36c89c3c@csnews>
#!/usr/bin/env perl
# pods - print out all pod paths
#
# this is a perl program not a shell script
# so that we can use the correct perl
system $^X, "-S", "stdpods";
system $^X, "-S", "pminst", "-l";
__END__
=head1 NAME
pods - print out all pod paths
=head1 DESCRIPTION
This program is a front end to print out the paths of all the standard
podpages and the modules.
=head1 SEE ALSO
faqpods(1), modpods(1), sitepods(1), podpath(1), pminst(1), and stdpod(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
I use `batshit' in an idiosyncratic fashion. --Andrew Hume
------------------------------
Date: 15 Feb 1999 15:11:44 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: podtoc -- show outline of pods
Message-Id: <36c89ba0@csnews>
#!/usr/bin/env perl
# podtoc -- show outline of pods
# tchrist@perl.com
$/ = '';
$inpod = 0;
while (<>) {
print "$ARGV\n" if $. == 1;
if ($inpod && /^=cut/) {
$inpod = 0;
next;
}
if (! $inpod && /^=(?!cut)\w+/) {
$inpod = 1;
}
if ($inpod) {
next unless /^=(?:head|item)/;
s/=head(\d)/' ' x ( $1 - 1 )/e;
s/=item/ * /;
s/\n+$/\n/;
print;
}
} continue {
if (eof) {
$inpod = 0;
close ARGV;
}
}
__END__
=head1 NAME
podtoc - show outline of pods
=head1 DESCRIPTION
This program shows the structure of one or more pod documents.
=head1 EXAMPLES
$ podtoc `pmpath CGI`
NAME
SYNOPSIS
ABSTRACT
DESCRIPTION
PROGRAMMING STYLE
CALLING CGI.PM ROUTINES
* 1. Use another name for the argument, if one is available. For
example, -value is an alias for -values.
* 2. Change the capitalization, e.g. -Values
(etc)
=head1 SEE ALSO
pod2man(1), perlpod(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
There ain't nothin' in this world that's worth being a snot over.
--Larry Wall in <1992Aug19.041614.6963@netlabs.com>
------------------------------
Date: 15 Feb 1999 15:12:53 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: sitepods - print out the paths to the modules
Message-Id: <36c89be5@csnews>
#!/usr/bin/env perl
# sitepods - print out the paths to the modules
# that this site added
#
# this is a perl program not a shell script
# so that we can use the correct perl
open(PROG, "$^X -S modpods |") || die "can't fork: $!";
while (<PROG>) {
print if /site_perl/;
}
__END__
=head1 NAME
sitepods - print out the paths to the modules that this site added
=head1 DESCRIPTION
This program shows the paths to module pods that are in
the I<site_perl> directories.
=head1 EXAMPLES
$ sitepods
/usr/local/devperl/lib/site_perl/5.00554/i686-linux/XML/Parser/Expat.pm
/usr/local/devperl/lib/site_perl/5.00554/i686-linux/XML/Parser.pm
You can also run this using alternate perl binaries, like so:
$ oldperl -S sitepods
....
=head1 SEE ALSO
faqpods(1), modpods(1), pods(1), podpath(1), and stdpod(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
What about WRITING it first and rationalizing it afterwords? :-)
--Larry Wall in <8162@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 15 Feb 1999 15:13:12 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: stdpods - print out the paths to the modules that came with Perl
Message-Id: <36c89bf8@csnews>
#!/usr/bin/env perl
# stdpods - print out the paths to the modules
# that this site added
#
# this is a perl program not a shell script
# so that we can use the correct perl
system("$^X -S basepods");
open(PROG, "$^X -S modpods |") || die "can't fork: $!";
while (<PROG>) {
print unless /site_perl/;
}
close PROG;
__END__
=head1 NAME
stdpods - print out the paths to the modules that came with Perl
=head1 DESCRIPTION
This program shows the paths to module pods that are I<not> in
the I<site_perl> directories. This is the documentation that
came with the standard system.
=head1 EXAMPLES
$ podgrep closure `stdpods`
=head1 SEE ALSO
podgrep(1), faqpods(1), modpods(1), pods(1), podpath(1), and sitepod(1).
=head1 AUTHOR and COPYRIGHT
Copyright (c) 1999 Tom Christiansen
This is free software. You may modify it and distribute it
under the Perl's Artistic Licence. Modified versions must be
clearly indicated.
--
Doing linear scans over an associative array is like trying to club someone
to death with a loaded Uzi. --Larry Wall
------------------------------
Date: 15 Feb 1999 20:26:40 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: String Compare
Message-Id: <7a9vu0$l6o$1@crchh14.us.nortel.com>
Paul J. Sala (psala@btv.ibm.com) wrote:
> I'm trying to construct a REGX that will determine if
> a string contains a character other than
> these: a-z A-Z 0-9 @ . _ -
> I tried:
> if ($MyStr =~
> /[\W\@\._-]+/)
> { dosomething; }
> else
> { dosomethingelse; }
try
/[^\w\@\._-]+/
------------------------------
Date: 15 Feb 1999 22:42:20 GMT
From: chud@acs2.acs.ucalgary.ca (Daqing Chu)
Subject: temp file
Message-Id: <7aa7sc$966@ds2.acs.ucalgary.ca>
How can I get a temp file name which does not exist in the
current directory in perl? I need to create a temp file.
Thanks for tips!
D. Chu
------------------------------
Date: 15 Feb 1999 22:57:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: temp file
Message-Id: <slrn7ch9ig.jel.sholden@pgrad.cs.usyd.edu.au>
On 15 Feb 1999 22:42:20 GMT, Daqing Chu <chud@acs2.acs.ucalgary.ca> wrote:
>How can I get a temp file name which does not exist in the
>current directory in perl? I need to create a temp file.
perlfaq5 : How do I make a temporary file name?
I admit it doesn't put it in the current directory, but putting a temporary
file in any other place then /tmp or $TMPDIR or whatever is the standard
place on your system seems a little silly to me.
What if the current directory isn't writable?
--
Sam
Perl was designed to be a mess (though in the nicest of possible ways).
--Larry Wall
------------------------------
Date: Mon, 15 Feb 1999 22:06:44 GMT
From: jouell@zdnetmail.com
Subject: trying to get all the data from an array, assigned from backticks?
Message-Id: <7aa5pf$825$1@nnrp1.dejanews.com>
Hi, I have search the NGs and taken a look at the man pages, however, I
clearly need someone who knows the finer points of perl.
I have a cgi script that does the following: it takes one argument from the
html form, and telnets to that value (with or without port), and displays the
value. I want to do this because in case I have a modem failure still do some
trouble shooting from a web browser.
My script works except I only get the first three lines. I believe am using a
version of cgi-lib.pl, but I just borrowed it from a cgi tutorial. It is a
limitation of the GET request?
Please do not brush this off and tell me to use cgi.pm, I'm sure it's
fantastic, but I think I'm pretty close here.
Here is my script and the HTML:
#!/usr/bin/perl -w
#
&readparse;
print "Content-type: text/html\n\n";
#
#********* BEGIN BODY********************
print "<HTML><HEAD><TITLE>Telnet Gateway 0.2</TITLE></HEAD><BODY>";
print "<H1>The results of your telnet session are:</H1>";
@telnet_array=`telnet $value`;
foreach $token (@telnet_array) {
print "$token <BR>"; #REM HTML is needed here!
}
print "</BODY></HTML>";
#******** END BODY************************
#
# EACH VALUE IN THE HTML FORM WILL BE CONTAINED IN
# THE THE @VALUE ARRAY.
sub readparse {
read(STDIN,$user_string,$ENV{'CONTENT_LENGTH'});
if (length($ENV{'QUERY_STRING'})>0) {$user_string=$ENV{'QUERY_STRING'}};
$user_string =~ s/\+/ /g;
@name_value_pairs = split(/&/,$user_string);
foreach $name_value_pair (@name_value_pairs) {
($keyword,$value) = split(/=/,$name_value_pair);
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/ge;
push(@value, "$value");
$user_data{$keyword} = $value;
if ($value=~/<!--\#exec/) {
print "Content-type: text/html\n\nNo SSI permitted";
exit;
};
};
};
-----------------------------
<HTML><HEAD><TITLE>Telnet Gateway 0.2</TITLE></HEAD><BODY>
<FORM NAME=form ACTION="../cgi-bin/telnet.cgi" METHOD=GET>
Enter a host and port (optional) to telnet to: <INPUT TYPE=TEXT SIZE=35
NAME=host><BR>
<P>
<INPUT TYPE=SUBMIT>
<INPUT TYPE=RESET>
</FORM>
</BODY>
</HTML>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 15 Feb 1999 17:41:00 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: V-day Perl Poetry
Message-Id: <Pine.A41.4.02.9902151739510.36046-100000@ginger.libs.uga.edu>
Don't you need
use Heart;
no break;
On Mon, 15 Feb 1999, Robert Bell wrote:
> Shouldn't that be:
> open (HEART, "+<for_me") or die of_grief();
> etc.
> One doesn't want to replace HEART, after all, but add to it.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4901
**************************************