[11300] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4900 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 15 18:07:29 1999

Date: Mon, 15 Feb 99 15:00:39 -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: 4900

Today's topics:
        add username and password script <kiml@worldnetla.net>
    Re: Creating individual arrays from an array <dboorstein@ixl.com>
    Re: Creating individual arrays from an array <ebohlman@netcom.com>
    Re: delete a line in a file <ludlow@us.ibm.com>
        Extracting data from netware 4.11 NDS <jgrain@breathemail.net>
        How do you calculate $yday if already know $mday, $mon  <bvis@mtv.com>
    Re: How do you calculate $yday if already know $mday, $ (I R A Aggie)
        installing Tk module from CPAN rolm@my-dejanews.com
        Javascript to browser via perl <mpusenja@zg.tel.hr>
    Re: Javascript to browser via perl (Sam Holden)
    Re: Making a Subject Index with Perl <ebohlman@netcom.com>
        Parsing <trenic@nortelnetworks.ca>
        Perl s///...can it be done in one line? (Dustin Christopher Preuitt)
    Re: REGEX $1, $2 ... array? (Bart Lateur)
    Re: rename files with perl <ludlow@us.ibm.com>
    Re: rename files with perl <tchrist@mox.perl.com>
        SRC: basepods - print out pod paths for the standard pe <tchrist@mox.perl.com>
        SRC: Devel::Loaded.pm - post-execution dump of loaded m <tchrist@mox.perl.com>
        SRC: faqpods - print out the paths to the faqs <tchrist@mox.perl.com>
        SRC: modpods - print out paths for the standard modules <tchrist@mox.perl.com>
        SRC: pfcat - cat out function definitions from perlfunc <tchrist@mox.perl.com>
        SRC: pmall - show all installed versions and descs <tchrist@mox.perl.com>
        SRC: pman - show a module's man page <tchrist@mox.perl.com>
        SRC: pmcat - page a module file <tchrist@mox.perl.com>
        SRC: pmdesc - show NAME section <tchrist@mox.perl.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 9 Feb 1999 04:54:48 -0600
From: "Kim Long" <kiml@worldnetla.net>
Subject: add username and password script
Message-Id: <36c89e22.0@209.4.101.246>

What would be the easiest way to write an automated Perl script to add users
on a Red Hat Linux system.  I read recently that using "expect" was not a
good answer.

KimL




------------------------------

Date: Mon, 15 Feb 1999 16:25:30 -0500
From: Dan Boorstein <dboorstein@ixl.com>
To: lchuck@home.com
Subject: Re: Creating individual arrays from an array
Message-Id: <36C890CA.5EFD0AB7@ixl.com>

might i recommend that you use a hash of array references instead?

my @furniture = ("chair", "table", "couch");
my %furniture = ();

foreach (@furniture) {
  @{ $furniture{$_} } = split '';
}

foreach (@furniture) {
  print "\@$_ = qw(";
  print join ' ', @{ $furniture{$_} };
  print ")\n";
}

cheers!

dan

lchuck@home.com wrote:
> 
> Sorry about the title of the message.  What I'm looking to do is to take an
> array of values (numbers, words, etc) and create an array for each of the
> values in the initial array.  Example:
> 
> @furniture=("chair", "table", "couch");
> 
> I would like to write a snippet of code that could take each item in the
> @furniture array and create seperate arrays, called @chair, @table, and
> @couch.

[snip]


------------------------------

Date: Mon, 15 Feb 1999 21:49:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Creating individual arrays from an array
Message-Id: <ebohlmanF77tz0.MG2@netcom.com>

lchuck@home.com wrote:
: Sorry about the title of the message.  What I'm looking to do is to take an
: array of values (numbers, words, etc) and create an array for each of the
: values in the initial array.  Example:

: @furniture=("chair", "table", "couch");

: I would like to write a snippet of code that could take each item in the
: @furniture array and create seperate arrays, called @chair, @table, and
: @couch.

No you wouldn't.  You'd like to create a hash of arrays (which Perl 
really implements as a hash of array *references*) keyed on the furniture 
names.  See perllol and perldsc.  Trying to create multiple arrays with 
names defined at run-time is usually a sign that you've gone down a 
cul-de-sac in your search for appropriate data structures.  Turn around 
and keep looking.


------------------------------

Date: Mon, 15 Feb 1999 15:43:45 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: delete a line in a file
Message-Id: <36C89511.8E286D4C@us.ibm.com>

Mark P. wrote:
> 
> Hi, I've read the Faq 5 on deleting but it only covers deleting the
> last line in a file. I want to delete a line based on the first item
> of a comma delimited file. First I print out the file and then the
> user can enter the value of the item to delete, which will then delete
> the whole line. The lines of the file look like this.

Well, you were looking in the right place.  I'll try to clarify a bit. 
Basically what you are _really_ wanting to do is not delete a line, but
rather print out the original file without _including_ the line.

foreach line in file
    Do we want to delete this line?
        NO  - print line to temporary output file
        YES - don't print line to temporary output file
Copy the temporary file over the original.
Delete temporary file.

The first example given in the FAQ is exactly what you want to do,
except that you'll have to change the innards of the while loop to fit
your needs.

while(<OLD>) {
    if ( # keep this line? ) {
        # yes 
        (print NEW $_) or die "can't write to $new: $!";
    }
}
    
-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


------------------------------

Date: 15 Feb 1999 22:47:22 GMT
From: "jgrain" <jgrain@breathemail.net>
Subject: Extracting data from netware 4.11 NDS
Message-Id: <01be5934$d3f6f060$01010101@webserver-win95>

Does anyone have example scripts to extract data from Netware 4.11 NDS
using data posted in a HTML form?

I know this is possible the setup I am running is a Netware 4.11 server
running Netscapes Fastrack Webserver.  A little research has shown that I
just need to be able to make calls, via server side scripting
to Netware's NDS api.  I have so far found no documentation that shows
specific examples using any
server side scripting


------------------------------

Date: Mon, 15 Feb 1999 16:04:01 -0600
From: "Bvis" <bvis@mtv.com>
Subject: How do you calculate $yday if already know $mday, $mon and $year?
Message-Id: <7aa5ak$9rj$1@ionews.ionet.net>

All,

I'm having trouble trying to figure out the day of the year if I already
know the date(month,day,year). I've heard of an external module called
Date::Manip , but I can't use external modules and need a built-in function
or some code to do the calculation. Anybody have any ideas? Any help is
greatly appreciated. Thanks.

P.S. Just adding up the days is not an option either. :)

Tommy





------------------------------

Date: 15 Feb 1999 22:40:44 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: How do you calculate $yday if already know $mday, $mon and $year?
Message-Id: <slrn7ch8o5.hd5.fl_aggie@enso.coaps.fsu.edu>

On Mon, 15 Feb 1999 16:04:01 -0600, Bvis <bvis@mtv.com> wrote:

+ I'm having trouble trying to figure out the day of the year if I already
+ know the date(month,day,year). I've heard of an external module called
+ Date::Manip , but I can't use external modules and need a built-in function
+ or some code to do the calculation. Anybody have any ideas? Any help is
+ greatly appreciated. Thanks.

     NAME
          Time::Local - efficiently compute time from local and GMT
          time

     SYNOPSIS
              $time = timelocal($sec,$min,$hours,$mday,$mon,$year);

So, just use this to get back an epoch time (remember to adjust the
month, 'cause localtime and allies deal with 0-11 months!), which
you can then feed into localtime and extract out the $yday value.

Yes, technically speaking, Time::Local external to your program.  It
is part of the standard perl distribution, so you should have no
problem accessing it.

James


------------------------------

Date: Mon, 15 Feb 1999 21:53:07 GMT
From: rolm@my-dejanews.com
Subject: installing Tk module from CPAN
Message-Id: <7aa4vv$77t$1@nnrp1.dejanews.com>

hi folks.  i'm trying to install the Tk module for perl using:

perl -MCPAN -e 'install Bundle::Tk;'

everything works fine until i get to the point where the script asks
for a wait server.  since i don't know where any wait servers are off hand,
(if you could provide a list of some, that would be great) I press return to
select the default.  immediately, i get the following error:

commit: wrote c:/perl5/lib/CPAN/Config.pm Can't find string terminator "'"
anywhere before EOF at -e line 1, <STDIN> chunk 23.

other details : i'm running ActiveState perl5_005 for win32 on WinNT 4.0 (some
may say that's my problem!) 8)

if you have any ideas how what is causing this problem, and/or how to solve
it, i'd be happy to hear from you!

mj

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: Mon, 15 Feb 1999 22:32:34 GMT
From: Marko Pusenjak <mpusenja@zg.tel.hr>
Subject: Javascript to browser via perl
Message-Id: <7aa7a2$9ah$1@nnrp1.dejanews.com>

I would like my perl script to send this command to browser:
javascript:top.text.location.reload(true);
The syntax:
Print "Location: javascript:top.text.location.reload(true);\N\N";
doesn't work.
How can I do that?

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


------------------------------

Date: 15 Feb 1999 22:42:15 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Javascript to browser via perl
Message-Id: <slrn7ch8m7.iu2.sholden@pgrad.cs.usyd.edu.au>

On Mon, 15 Feb 1999 22:32:34 GMT, Marko Pusenjak <mpusenja@zg.tel.hr> wrote:
>I would like my perl script to send this command to browser:
>javascript:top.text.location.reload(true);
>The syntax:
>Print "Location: javascript:top.text.location.reload(true);\N\N";
>doesn't work.
>How can I do that?

Go and ask in a somewhere where people know about web stuff. This is
not that place.


-- 
Sam

Just don't create a file called -rf.  :-)
	--Larry Wall


------------------------------

Date: Mon, 15 Feb 1999 22:05:42 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Making a Subject Index with Perl
Message-Id: <ebohlmanF77upI.B3@netcom.com>

Jonathan Eaton <jeaton@tamworth.u-net.com> wrote:
: I need some help with using Perl to create a subject index for book titles.

: I have a flat file of book records in which each title may have one or more
: subject terms (delimited by a slash), as follows:

: Title  |  Date  |  Subject Term(s)

: Beginner's Course in Finance|1998|FINANCE
: Finance for Accountants|1995|FINANCE/ACCOUNTANCY
: Marketing for Financial Services|1997|FINANCE/MARKETING

: I want to generate an alphabetically sorted subject index as follows (using
: above as example)

: ACCOUNTING
:     Finance for Accountants

: FINANCE
:     Beginner's Course in Finance
:     Finance for Accountants

[snip]

WARNING!  UNTESTED!

For simplicity, assume we're reading from STDIN and writing to STDOUT.

#!perl -w
use strict;
my %subjects;
while (<>) {
  chomp;
  my ($title,$date,$termlist) = split /\|/;
  foreach $term (split (/\//, $termlist)) { 
    push @{$subjects{$term}}, $title;
  }
}
foreach $term (sort keys %subjects) {
  print "$term\n";
  foreach my $title (sort @{$subjects{$term}}) {
    print "\t$title\n";
  }
}
 


------------------------------

Date: Mon, 15 Feb 1999 17:27:08 -0500
From: Tom Renic <trenic@nortelnetworks.ca>
Subject: Parsing
Message-Id: <36C89F3C.32560057@nortelnetworks.ca>

Hello group,

I've asked this question in the past and received responses, yet
for some reason nothing I try works. Could someone please take
a look at the sample code and let me know what they think?

# The variables are being renamed for easier use within the script

$Proposal = $in{Proposal};
$CustomerName = $in{CustomerName};
$OfficeAddress = $in{OfficeAddress};
$ContactName = $in{ContactName};
$ContactPhone = $in{ContactPhone};
$ContactAddress = $in{ContactAddress};

# I then have an if statement which checks for mandatory fields
if (blah, blah etc)
{
       #------This is where I am having problems. Save comments to a
file----

       open(FILE, ">>$directory/request_services.txt")
               print FILE
"$Proposal~$CustomerName~$OfficeAddress~$ContactName~$ContactPhone~$ContactAddress";

               # All I want to be able to do is take the information and
have printed to a text file on one line.
               # The problem begins when I get to the $OfficeAddress
variable, since an address has usually more than one
               # line, seperated by enter characters. What I would like
to do is replace the enter strokes with a comma.
               # I've tried all that has been recommended but have not
been able to get the right code.

Can someone PLEASE give me a hand with this??????



------------------------------

Date: 15 Feb 1999 22:37:03 GMT
From: preuitt@ix.cs.uoregon.edu (Dustin Christopher Preuitt)
Subject: Perl s///...can it be done in one line?
Message-Id: <7aa7if$bmi$1@helix.cs.uoregon.edu>


Okay, I'm trying to figure out if I can make the following changes with one line of code

if the line reads like this:

  billy bob likes to shout, "Hey Gordo McMourdo" to his brother paul.

I want to add a '!' after every capital letter in the quotes. So the modified
line would be:

  billy bob likes to shout, "H!ey G!ordo M!cM!ourdo" to his brother paul.

So...I'm stuck. I can't figure out how to do more than one Capital within
the quotes...


$line =~ s/"([^A-Z]*)([A-Z])(what else do I need?)"/"$1.$2.???."/g

Is it possible?




------------------------------

Date: Mon, 15 Feb 1999 21:58:30 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: REGEX $1, $2 ... array?
Message-Id: <36c995e9.12639341@news.skynet.be>

Larry Rosler wrote:

>> Why isn't there a special array that contains
>> $1, $2, $3, etc . . . from application of a regex.
>> This would really make things easier.
>
>Why do you nead a special array?  Use an array of your own.

That is not available in s///.

	Bart.


------------------------------

Date: Mon, 15 Feb 1999 16:03:33 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: rename files with perl
Message-Id: <36C899B5.79CCB5EC@us.ibm.com>

Derrick MacPherson wrote:
> I am in need of a huge hand, I was wondering if someone can help me.
> I am needing to rename

perldoc -f rename

> a list of files.

perldoc -f glob
perldoc File::Find

> The files are in the format ?-*.pnt and ?-*.scan
> (so m-31.pnt and m-31.scan)

perldoc perlre

-- 
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)


------------------------------

Date: 15 Feb 1999 14:59:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: rename files with perl
Message-Id: <36c898b6@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Derrick MacPherson <derrick@mercuryfilmworks.com> writes:
:I am in need of a huge hand, I was wondering if someone can help me.
:I am needing to rename a list of files. The files are in the format
:?-*.pnt and ?-*.scan (so m-31.pnt and m-31.scan)
:
:I would like at least to be able to change the first character to a
:different letter.
:
:Bonus points if it can include moving directories, and flexibility..

#!/usr/bin/perl
'di';
'ig00';
#
# $Header: rename,v 3.0.1.2 90/08/09 03:17:57 lwall Locked $
#
# $Log:	rename,v $
# Revision 3.0.1.2  90/08/09  03:17:57  lwall
# patch19: added man page for relink and rename
# 

if ($ARGV[0] eq '-i') {
    shift;
    if (open(TTYIN, "</dev/tty") && open(TTYOUT,">/dev/tty")) {
	$inspect++;
	select((select(TTYOUT),$|=1)[0]);
    } 
}
($op = shift) || die "Usage: rename [-i] perlexpr [filenames]\n";
if (!@ARGV) {
    @ARGV = <STDIN>;
    chop(@ARGV);
}
for (@ARGV) {
    unless (-e) {
	print STDERR "$0: $_: $!\n";
	$status = 1;
	next;
    } 
    $was = $_;
    eval $op;
    die $@ if $@;
    if ($was ne $_) {
	if ($inspect && -e) {
	    print TTYOUT "remove $_? ";
	    next unless <TTYIN> =~ /^y/i;
	} 
	unless (rename($was, $_)) {
	    print STDERR "$0: can't rename $was to $_: $!\n";
	    $status = 1;
	}
    } 
}
exit $status;
##############################################################################

	# These next few lines are legal in both Perl and nroff.

 .00;			# finish .ig
 
'di			\" finish diversion--previous line must be blank
 .nr nl 0-1		\" fake up transition to first page again
 .nr % 0			\" start at page 1
';<<'.ex'; #__END__ ############# From here on it's a standard manual page ############
 .TH RENAME 1 "July 30, 1990"
 .AT 3
 .SH NAME
rename \- renames multiple files
 .SH SYNOPSIS
 .B rename [-i] perlexpr [files]
 .SH DESCRIPTION
 .I Rename
renames the filenames supplied according to the rule specified as the
first argument.
The argument is a Perl expression which is expected to modify the $_
string in Perl for at least some of the filenames specified.
If a given filename is not modified by the expression, it will not be
renamed.
If no filenames are given on the command line, filenames will be read
via standard input.
 .PP
The 
 .B \-i
flag will prompt to remove the old file first if it exists.  This
flag will be ignored if there is no tty.
 .PP
For example, to rename all files matching *.bak to strip the extension,
you might say
 .nf

	rename 's/\e.bak$//' *.bak

 .fi
To translate uppercase names to lower, you'd use
 .nf

	rename 'y/A-Z/a-z/' *

 .fi
To do the same thing but leave Makefiles unharmed:
 .nf

	rename 'y/A-Z/a-z/ unless /^Make/' *

 .fi
To rename all the *.f files to *.BAD, you'd use
 .nf

	rename 's/\e.f$/.BAD/' *.f

 .SH ENVIRONMENT
 .fi
No environment variables are used.
 .SH AUTHOR
Larry Wall
 .SH "SEE ALSO"
mv(1)
 .br
perl(1)
 .SH DIAGNOSTICS
If you give an invalid Perl expression you'll get a syntax error.
 .SH BUGS
 .I Rename
does not check for the existence of target filenames unless you
specifty the 
 .B \-i
flag, so use with care.
 .ex

-- 
"Twisted cleverness is my only skill as a programmer." --Elizabeth Zwicky


------------------------------

Date: 15 Feb 1999 15:13:29 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: basepods - print out pod paths for the standard perl manpages 
Message-Id: <36c89c09@csnews>

#!/usr/bin/env perl
# basepods - print out the standard perl*.pod manpages pod paths

use Config;
$lib = "$Config{'installprivlib'}/pod";
opendir(LIB, $lib) || die "$0: can't opendir $lib: $!\n";
while ($_ = readdir(LIB)) { 
    print "$lib/$_\n" if /\.pod$/;
} 

__END__

=head1 NAME

basepods - print out pod paths for the standard perl manpages 

=head1 DESCRIPTION

This program uses your configuration's C<installprivlib> directory
to look up the full paths to those pod pages.  Any files in that
directory whose names end in C<.pod> will be printed to the standard
output, one per line.  This is normally used in backticks to produce
a list of filenames for other commands.

=head1 EXAMPLES

    $ podgrep typeglob `basepods`

    $ basepods | grep delt
    /usr/local/devperl/lib/5.00554/pod/perl5004delta.pod
    /usr/local/devperl/lib/5.00554/pod/perl5005delta.pod
    /usr/local/devperl/lib/5.00554/pod/perldelta.pod

You can also run this using alternate perl binaries, like so:

    $ oldperl -S basepods | grep delt
    /usr/lib/perl5/pod/perldelta.pod

    $ podgrep -i thread `filsperl basepods | grep delt`
    ....

=head1 SEE ALSO

faqpods(1), modpods(1), pods(1), sitepod(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.
-- 
    "The young think they are immortal, and are determined to prove otherwise."
    	--Larry Wall


------------------------------

Date: 15 Feb 1999 15:11:10 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: Devel::Loaded.pm - post-execution dump of loaded modules
Message-Id: <36c89b7e@csnews>

(needed by plxload)

# Devel/Loaded.pm -- show what files were loaded 
# tchrist@perl.com

package Devel::Loaded;

$VERSION = 1;

BEGIN { %Seen = %INC } 

END { 

    delete $INC{"Loaded.pm"};

    for my $path (values %INC) {
	print "$path\n" unless $Seen{$path};
    } 

}

1;

__END__

=head1 NAME

Devel::Loaded - Post-execution dump of loaded modules

=head1 SYNOPSIS

    perl -MDevel::Loaded -Sc programname 2>/dev/null

=head1 DESCRIPTION

The Devel::Loaded module installs an at-exit handler to generate a dump of
all the module files used by a Perl program.  If used in conjunction with
a I<perl -c>, you find those files loaded in at compile time with C<use>.
If you are willing to wait until after the program runs, you can get
them all.

=head1 EXAMPLES

This is compile-time only:

    $ perl -MDevel::Loaded -S -c perldoc 2>/dev/null
    /usr/local/devperl/lib/5.00554/Exporter.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/Config.pm
    /usr/local/devperl/lib/5.00554/Getopt/Std.pm

This will also catch run-time loads:

    #!/usr/bin/perl
    use Devel::Loaded;
    ...

=head1 SEE ALSO

The I<plxload> and the I<pmload> programs, which use
this technique.

=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:13:41 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: faqpods - print out the paths to the faqs
Message-Id: <36c89c15@csnews>

#!/usr/bin/env perl
# faqpods - print out the paths to the faqs
# 
# this is a perl program not a shell script
# so that we can use the correct perl 

open(PROG, "$^X -S basepods |") || die "can't fork: $!";
while (<PROG>) {
    print if /perlfaq/;
} 

__END__

=head1 NAME

faqpods - print out pod paths for the standard perl faqs

=head1 DESCRIPTION

This program uses your configuration's C<installprivlib> directory
to look up the full paths to those pod pages.  Any files in that
directory whose names start in C<perlfaq> will be printed to the standard
output, one per line.  This is normally used in backticks to produce
a list of filenames for other commands.

=head1 EXAMPLES

    $ podgrep typeglob `faqpods`
    ....

You can also run this using alternate perl binaries, like so:

    $ podgrep -i thread `filsperl faqpods`
    ....

=head1 SEE ALSO

basepods(1), modpods(1), pods(1), sitepod(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.
-- 
*bp++ = i;      /* now go back to screaming loop */
    --Larry Wall, from perl/sv.c in the v5.0 perl distribution


------------------------------

Date: 15 Feb 1999 15:14:02 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: modpods - print out paths for the standard modules
Message-Id: <36c89c2a@csnews>

#!/usr/bin/env perl
# modpods - print out all module pod paths
#
# this is a perl program not a shell script
# so that we can use the correct perl 

system $^X, "-S", "pminst", "-l";

__END__

=head1 NAME

modpods - print out paths for the standard modules

=head1 DESCRIPTION

This program outputs the paths to all installed modules on your systems.
This includes both the standard modules (which the I<stdpods> command
produces) and the site-specific ones (which the I<sitepods> command
produces).

This is just a front-end for calling I<pminst -l>, supplied
to make it more obvious what it does.  

=head1 EXAMPLE

This finds all the modules whose documentation mentions
destructors, and cats it out at you.

    $ podgrep -i destructor `modpods`

    =head1 /usr/local/devperl/lib/5.00554/i686-linux/DB_File.pm chunk 371

    Having read L<perltie> you will probably have already guessed that the
    error is caused by the extra copy of the tied object stored in C<$X>.
    If you haven't, then the problem boils down to the fact that the
    B<DB_File> destructor, DESTROY, will not be called until I<all>
    references to the tied object are destroyed. Both the tied variable,
    C<%x>, and C<$X> above hold a reference to the object. The call to
    untie() will destroy the first, but C<$X> still holds a valid
    reference, so the destructor will not get called and the database file
    F<tst.fil> will remain open. The fact that Berkeley DB then reports the
    attempt to open a database that is alreday open via the catch-all
    "Invalid argument" doesn't help.

    =head1 /usr/local/devperl/lib/5.00554/Tie/Array.pm chunk 40

    Normal object destructor method.

=head1 SEE ALSO

podgrep(1), modpods(1), pods(1), sitepods(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.
-- 
Let us be charitable, and call it a misleading feature  :-)
        --Larry Wall in <2609@jato.Jpl.Nasa.Gov>


------------------------------

Date: 15 Feb 1999 15:09:52 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pfcat - cat out function definitions from perlfunc 
Message-Id: <36c89b30@csnews>

#!/usr/bin/env perl
# pfcat - cat out function definitions from perlfunc 
# tchrist@perl.com
# 
# this is a command of its own so it can find the right version


@options = ();
while ($ARGV[0] =~ /^-/) {
    push @options, shift @ARGV;
} 

die "usage: $0 function\n" unless @ARGV;

system "$^X podgrep -h @options '@ARGV' `$^X podpath perlfunc`";
exit ($? != 0);

__END__

=head1 NAME

pfgrep - grep out function definitions from perlfunc 

=head1 DESCRIPTION

This program uses I<podgrep> program to search your configuration's
L<perlfunc> for function definitions.  It honors a B<-f> flag to 
format through I<pod2text> and a B<-p> flag to send the output
through the pager.  (Actually, it just passes these to I<podgrep>.)

=head1 EXAMPLES

    $ pfcat seek
    (find all seek functions (including sysseek))

    $ pfcat -pf sprintf
    (sprintf function is formated and sent to pager)

    $ pfcat -f '\bint\b'
    /usr/local/devperl/lib/5.00554/pod/perlfunc.pod chunk 506
    int EXPR
    int

    Returns the integer portion of EXPR. If EXPR is omitted, uses
    `$_'. You should not use this for rounding, because it truncates
    towards `0', and because machine representations of floating point
    numbers can sometimes produce counterintuitive results. Usually
    `sprintf()' or `printf()', or the `POSIX::floor' or `POSIX::ceil'
    functions, would serve you better.

You can also run this using alternate perl binaries, like so:

    $ oldperl -S pfcat open
    ....

=head1 SEE ALSO

podgrep(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.
-- 
MSDOS isn't dead.  It just smells like it.


------------------------------

Date: 15 Feb 1999 15:12:07 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmall - show all installed versions and descs
Message-Id: <36c89bb7@csnews>

#!/usr/bin/env perl
# pmall -- show all installed versions and descs
# tchrist@perl.com

use strict;
use File::Find	qw(find);
use Getopt::Std	qw(getopts);
use Carp;

use vars (
    q!$opt_v!,		# give debug info
    q!$opt_w!,		# warn about missing descs on modules
    q!$opt_a!,		# include relative paths
    q!$opt_s!,		# sort output within each directory
);

$| = 1;

getopts('wvas') || die "bad usage";

@ARGV = @INC unless @ARGV;


# Globals.  wish I didn't really have to do this.
use vars (
    q!$Start_Dir!,	# The top directory find was called with
    q!%Future!,		# topdirs find will handle later
);

my $Module;

if ($opt_s) {
    if (open(ME, "-|")) {
	$/ = '';
	while (<ME>) {
	    chomp;
	    print join("\n", sort split /\n/), "\n";
	} 
	exit;
    } 
} 

MAIN: { 
    my %visited;
    my ($dev,$ino);

    @Future{@ARGV} = (1) x @ARGV;

    foreach $Start_Dir (@ARGV) { 
	delete $Future{$Start_Dir};

	print "\n<<Modules from $Start_Dir>>\n\n"
	    if $opt_v;

	next unless ($dev,$ino) = stat($Start_Dir);
	next if $visited{$dev,$ino}++;
	next unless $opt_a || $Start_Dir =~ m!^/!;

	find(\&wanted, $Start_Dir);
    } 
    exit;
}

sub modname { 
    local $_ = $File::Find::name;

    if (index($_, $Start_Dir . '/') == 0) {
	substr($_, 0, 1+length($Start_Dir)) = '';
    } 

    s { /              }	{::}gx;
    s { \.p(m|od)$     }	{}x;

    return $_;
}

sub wanted { 
    if ( $Future{$File::Find::name} ) { 
	warn "\t(Skipping $File::Find::name, qui venit in futuro.)\n"
	    if 0 and $opt_v;
	$File::Find::prune = 1;
	return;
    } 
    return unless /\.pm$/ && -f;
    $Module = &modname;

    my    $file = $_;

    unless (open(POD, "< $file")) {
	warn "\tcannot open $file: $!";
	    # if $opt_w;
	return 0;
    } 

    $: = " -:";

    local $/ = '';
    local $_;
    while (<POD>) {
	if (/=head\d\s+NAME/) {
	    chomp($_ = <POD>);
	    s/^.*?-\s+//s; 
	    s/\n/ /g;
	    #write;
	    my $v;
	    if (defined ($v = getversion($Module))) {
		print "$Module ($v) ";
	    } else {
		print "$Module ";
	    }
	    print "- $_\n";
	    return 1;
	} 
    } 

    warn "\t(MISSING DESC FOR $File::Find::name)\n" 
	if $opt_w;

    return 0;
} 

sub getversion {
    my $mod = shift;
    my $vers = `$^X -m$mod -e 'print \$${mod}::VERSION' 2>&1`;
    #my $vers = `$^X -m$mod -e 'print \$${mod}::VERSION' 2>/dev/null`;
    # 2> due to errors from MM_Unix etc
    $vers =~ s/^\s*(.*?)\s*$/$1/; # why is there whitespace here??
    return ($vers || undef);
}

sub getversion_internal {
    # This should really use system(), because otherwise we bloat.
    my $mod = shift;
    local $SIG{__WARN__} = sub {};
    eval "require $mod";
    if ($@) {
	warn "Cannot require $mod -- $@\n"
	    if $opt_v;
	return;
    } 
    my $vers;
    {
	no strict 'refs';
	return unless defined ($vers = ${ $mod . "::VERSION" });
    }
    $vers =~ s/^\s*(.*?)\s*$/$1/; # why is there whitespace here??
    return $vers;
} 


format  =
^<<<<<<<<<<<<<<<<<~~^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
$Module,	$_
 .

__END__

=head1 NAME

pmall - show all installed versions and descs

=head1 SYNOPSIS

    pmall [-d] [-w] [-a] [-s]

pmall - show all installed versions and descs

=head1 DESCRIPTION

This program runs through all your installed modules
and tells you what they're for and what version 
number they are at.  

The following options are honored:

=over 4

=item -v

give debug info

=item -w

warn about missing descriptions on modules

=item -a

include relative paths

=item -s

sort output within each directory

=back

=head1 HISTORICAL NOTE

This program used to be called I<pmdesc> and is included in I<The Perl
Cookbook> under that name.  However, that name has been usurped by 
a simpler program.

For example, to find the versions of what is in your site-specific
directory, the simpler I<pmdesc> might be preferred:

    $ pmdesc `pminst -s | perl -lane 'print $F[1] if $F[0] =~ /site/'`
    XML::Parser::Expat (2.19) - Lowlevel access to James Clark's expat XML parser
    XML::Parser (2.19) - A perl module for parsing XML documents

=head1 KNOWN BUGS

This program takes a long time to run.

Some modules don't work right (CPAN.pm, ExtUtils) because of noisy things
they do at compile time or poor formatting of the pod.

=head1 SEE ALSO

pmdesc(1)
pmvers(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 dunno, I dream in Perl sometimes...
                    --Larry Wall in  <8538@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: 15 Feb 1999 15:04:00 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pman - show a module's man page
Message-Id: <36c899d0@csnews>

#!/usr/bin/env perl
# pman -- show a module's man page
# tchrist@perl.com

BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module ...\n" unless @ARGV }

use FindBin qw($Bin);

$errors = 0;

unless ($pager = $ENV{PAGER}) {
    require Config;
    $pager = $Config::Config{"pager"} || "more";
} 

for $module (@ARGV) { 
    my $path =  `$Bin/pmpath $module`;
    if ($?) {
	$errors++;
	next;
    } 
    chomp $path;
    system "pod2text $path | $pager";
    $errors += ($? != 1);
}

exit($errors != 0);

__END__

=head1 NAME

pman - show a module's man page

=head1 DESCRIPTION

Send a module's pod through pod2text and your pager.

This is mostly here for people too lazy to type

    $ pod2text `pmpath CGI` | $PAGER

=head1 EXAMPLES

    $ pman CGI
    $ pman Curses

Or running under different versions of Perl: 

    $ oldperl -S pman CGI
    $ filsperl -S pman Threads

=head1 SEE ALSO

pod2text(1), perlpod(1), pod2man(1), pod2html(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 power tool is not a toy.  Unix is a power tool.


------------------------------

Date: 15 Feb 1999 15:04:23 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmcat - page a module file
Message-Id: <36c899e7@csnews>

#!/usr/bin/env perl
# pmcat -- page a module file
# tchrist@perl.com

BEGIN { $^W = 1 }
BEGIN { die "usage: $0 module ...\n" unless @ARGV }

use FindBin qw($Bin);

unless ($pager = $ENV{PAGER}) {
    require Config;
    $pager = $Config::Config{"pager"} || "more";
} 

exec "$pager `$^X $Bin/pmpath @ARGV`";

__END__

=head1 NAME

pmcat - page through a module file

=head1 DESCRIPTION

Given a module name, figure out the path name and send
that to the user's pager.

    $ pmcat CGI

This works also on alternate installed versions of Perl:

    $ oldperl -S pmcat strict

    $ filsperl -S pmcat Threads

This command is mostly here for people too lazy to type

    $ more `pmpath CGI` 

=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.
-- 
    I know it's weird, but it does make it easier to write poetry in perl.    :-)
                    --Larry Wall in <7865@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: 15 Feb 1999 15:04:56 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: SRC: pmdesc - show NAME section
Message-Id: <36c89a08@csnews>

#!/usr/bin/env perl
# pmdesc -- show NAME section
# tchrist@perl.com

BEGIN { $^W = 1 }

use FindBin qw($Bin);

$errors = 0;

MODULE: for $module (@ARGV) {
    $fullpath = `$^X $Bin/pmpath $module`;
    if ($?) {
	$errors++;
	next;
    } 
    chomp $fullpath;
    unless (open(POD, "< $fullpath")) {
	warn "$0: cannot open $fullpath: $!";
	$errors++;
	next;
    } 
    local $/ = '';
    local $_;
    while (<POD>) {
        if (/=head\d\s+NAME/) {
            chomp($_ = <POD>);
            s/^.*?-\s+//s; 
            s/\n/ /g;
            #write;
            my $v;
            if (defined ($vers = getversion($module))) {
                print "$module ($vers) ";
            } else {
                print "$module ";
            }
            print "- $_\n";
	    next MODULE;
        } 
    } 
    print "no description found\n";
    $errors++;
} 

sub getversion {
    my $vers = `$^X $Bin/pmvers $module 2>/dev/null`;
    return if $?;
    chomp $vers;
    return $vers;
} 

exit ($errors != 0);

__END__

=head1 NAME

pmdesc - print out version and whatis description of perl modules

=head1 DESCRIPTION

Given one or more module names, show the version number (if known)
and the `whatis' line, that is, the NAME section's description,
typically used for generation whatis databases.

=head1 EXAMPLES

    $ pmdesc IO::Socket
    IO::Socket (1.25) - Object interface to socket communications

    $ oldperl pmdesc IO::Socket
    IO::Socket (1.1603) - Object interface to socket communications

    $ pmdesc `pminst -s | perl -lane 'print $F[1] if $F[0] =~ /site/'`
    XML::Parser::Expat (2.19) - Lowlevel access to James Clark's expat XML parser
    XML::Parser (2.19) - A perl module for parsing XML documents

=head1 RESTRICTIONS

This only works on modules.  It should also work on filenames, but then
it's a bit tricky finding out the package to call the VERSION method on.

=head1 SEE ALSO

pmdesc(1)
pminst(1)
pmpath(1)
pmvers(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.
-- 
 Nothing is created by a team or an organization.  Every new idea comes out
 of a single human mind.  -- Admiral Rickover


------------------------------

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 4900
**************************************

home help back first fref pref prev next nref lref last post