[11945] in Perl-Users-Digest
Perl-Users Digest, Issue: 5545 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 2 20:07:19 1999
Date: Sun, 2 May 99 17:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 2 May 1999 Volume: 8 Number: 5545
Today's topics:
Re: a complex associative array problem (Tad McClellan)
Re: An attempt to compare the performance of perl vs co <cassell@mail.cor.epa.gov>
Re: Create a new file <cassell@mail.cor.epa.gov>
Re: Debug - Single step ? <tchrist@mox.perl.com>
Re: Debug - Single step ? <ebohlman@netcom.com>
Re: Debug - Single step ? <tchrist@mox.perl.com>
Re: E-Mail Attachments <cassell@mail.cor.epa.gov>
for ($i = 0, $i <= 29470, $i++} -- 29470 too high? <dbohling@earthlink.net>
Re: for ($i = 0, $i <= 29470, $i++} -- 29470 too high? (Tad McClellan)
Re: for ($i = 0, $i <= 29470, $i++} -- 29470 too high? <rick.delaney@home.com>
Re: Frequent Posters... gurus. I will regret this post <flavell@mail.cern.ch>
Re: HELP! - perl script won't write?!? (Tad McClellan)
looking for ping time collector frankr@darbygroup.com
Need help creating Date arrays (Lyndon F. Bartels)
Re: perl and C <ebohlman@netcom.com>
Re: RegEx for matching Mbx "From " delimeter (Larry Rosler)
simple CGI program <yuriyt@ix.netcom.com>
Re: simple CGI program (Sam Holden)
Re: Throw a person a fish... <tchrist@mox.perl.com>
Re: unos problemitas <tchrist@mox.perl.com>
Using serial console as input/output on multiple serial <portboy@home.com>
writing binary file <frankhale@worldnet.att.net>
Re: writing binary file <tchrist@mox.perl.com>
Re: writing binary file <rick.delaney@home.com>
writing binary files in Perl <frankhale@worldnet.att.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 2 May 1999 13:10:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: a complex associative array problem
Message-Id: <tu0ig7.oe1.ln@magna.metronet.com>
David Cassell (cassell@mail.cor.epa.gov) wrote:
: Jonathan Stowe wrote:
: >
: > On Thu, 29 Apr 1999 21:13:39 GMT du_bing@my-dejanews.com wrote:
: > >
: > >
: > > I fixed the problem myself.
: > >
: >
: > Although it might seem a minor thing, it is generally considered polite
: > in these cases to post back the solution to the group in order that those
: > who might find themselves in a similar position can find the answer.
: >
: > Oh and so we jaded hackers can have a little fun at your expense picking
: > your code to bits ;-}
: In the words of Bob Trieger, "Post here, get mocked here." :-)
But it should have a subtitle or something:
and learn something valuable in the process!
Nothing worth having is free :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 02 May 1999 16:24:21 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: An attempt to compare the performance of perl vs compiled perl vs C
Message-Id: <372CDEA5.3A2D740D@mail.cor.epa.gov>
Steven Elliott wrote:
>
> [trim of post]
>
> The program I chose (sum_array.{pl,c}) is small, mathematically
> intensive and makes many array accesses. This I believe, and as I
> think my test results demonstrate, strongly favors C. My intent in
It certainly should. However, see my notes below.
> choosing an example that strongly favors C was not to be deprecate perl
> but to determine what the worst case scenario might be in terms of my
> having to rewrite something into C. I love perl.
I found your Perl program impossible to access, so I can't evaluate
it. Perhaps you might want to post it...
But these times suggest that there might be some non-optimal
elements in your Perl code.
Tom Christiansen's [possibly mythological] Perl vs. C bet with
Rob Kolstad makes me wonder if a factor of 29 [or so] is a little
high to expect, even for something like this. The rumor I heard
said that Tom never had to pay off on his bet.
> # perl uncompiled (sum_array.pl) -> 58 sec:
> # perl compiled to bytecode (from sum_array.pl) -> 58 sec:
> # perl compiled to an executable (from sum_array.pl) -> 22 sec:
I really didn't expect to see this large of a change here.
> # C compiled to an executable (from sum_array.c) -> 2 sec:
If it's easier and faster for you to write efficient C code, then
that seems like a reasonable choice to me.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Sun, 02 May 1999 16:30:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Create a new file
Message-Id: <372CE006.6D10B7F0@mail.cor.epa.gov>
Lawrence Brendish wrote:
>
> Hi,
>
> Very new to perl (less than 24 hours!), how do you create a new file using a
> perl script?
>
> I seem to come across how to rename, delete, etc. but can't find how to
> create a new one.
Try typing at a command prompt:
perldoc -f open
That should give you a start. But you ought to look for the perlopentut
page.. which oddly enough, Tom Christiansen posted in this newsgroup
just hours ago. Use DejaNews to get it, or look on your own system
where Perl is installed, for one of: the perlopentut pod, or the
HTML version of perlopentut [already on your system if you have a
modern version of ActiveState Perl].
Also, you might want to look at "Learning Perl" from O'Reilly and
see if it's the right starting level for you. It's a great book
for a beginner to PErl who is *not* a beginner to programming.
> Thanks in advance,
You're welcome after the fact,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 2 May 1999 17:30:04 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Debug - Single step ?
Message-Id: <372cdffc@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
David Cassell <cassell@mail.cor.epa.gov> writes:
:of the nifty Perl programs which help you. Try typing at a
:comand prompt:
: perldoc perldebug
perldoc is not nifty. It's an embarrassment.
--tom
--
Timesharing: the use of several people by the computer
------------------------------
Date: Sun, 2 May 1999 23:47:07 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Debug - Single step ?
Message-Id: <ebohlmanFB4q2K.Guw@netcom.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
: In comp.lang.perl.misc,
: David Cassell <cassell@mail.cor.epa.gov> writes:
: :of the nifty Perl programs which help you. Try typing at a
: :comand prompt:
: : perldoc perldebug
: perldoc is not nifty. It's an embarrassment.
In terms of functionality, implementation, or both? If the former,
what's your (and anyone else's) idea of the dream documentation-reading
program?
------------------------------
Date: 2 May 1999 17:58:29 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Debug - Single step ?
Message-Id: <372ce6a5@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Eric Bohlman <ebohlman@netcom.com> writes:
:Tom Christiansen <tchrist@mox.perl.com> wrote:
:: In comp.lang.perl.misc,
:: David Cassell <cassell@mail.cor.epa.gov> writes:
:: :of the nifty Perl programs which help you. Try typing at a
:: :comand prompt:
:: : perldoc perldebug
:
:: perldoc is not nifty. It's an embarrassment.
:
:In terms of functionality, implementation, or both? If the former,
:what's your (and anyone else's) idea of the dream documentation-reading
:program?
The problem with perldoc is that it is not generalizable or extensible
to any docset. It only works for the perl distribution, and then
only idiosyncratically. It was not designed. It tries to do many
different unrelated things. It was kludged as one hulking brute of an
application. I believe that the wrong set of primitives were chosen.
Actually, primitives weren't chosen, but special hacks added. That's
the problem. It should be several separate interchangeable tools. With
interchangeability, comes power. This is not a power tool. It's a hack,
one that grew beyond its purpose into something that should not live.
Here are the perldoc options:
-h help
Yes, that one is fine.
-v verbose
So is that.
But the rest are range from dubious to lousy:
-t text output
That's merely:
pod2text `pmpath MODULE`
as opposed to:
pod2man `pmpath MODULE` | nroff -man
-u unformatted
That's merely:
cat `pmpath MODULE`
-m module
That's merely:
$PAGER `pmpath MODULE`
-l file name only
That's merely:
pmpath MODULE
-F file names
That's merely:
pod2text FILE
or
pod2man FILE | nroff -man
-f perlfunc
That's indicative of a poorly thought out feature. Rather
than hacking perldoc, one should have fixed the documentation
installation itself. You can see this is dumb because it should
not be embarrassginly hardcoded to work only for things from
perlfunc. What about =items somewhere else? Of course, those
=itme function functions should all be in their own separate
documents, as splitpod produces. What about catting a function
doc from POSIX.pod? How about catting the real function from
POSIX.pm? Why is this hardcoded?
-q perlfaq
Once again, a very bad idea. Why should you there be
so much built-in knowledge? What if you want to check
the =head[12]s on other documents? Why is this hardcoded?
What about other docsets?
-X use an index if present
Yet another hack. Does this work for a non-perl-distribution
tree? What builds this? What is this really? Isn't this just
a bad substitute for the whatis database? How about a glimpse
database? Or lqtext? Or anything general-purpose and reusable?
We should have either written a portable replacement for man that groks
pods, or we should have written nice interchangeable pieces.
We did neither.
Instead, we have this anti-toolthink hack that just keeps getting worse
and worse as more kludges are stuffed into it.
--tom
http://language.perl.com/misc/pmtools-1.00.tar.gz
% cat pmtools/README
=========================================================
pmpath - show the module's full path
$ pmpath Carp
/usr/local/devperl/lib/5.00554/Carp.pm
=========================================================
pmvers - get a module version number
$ pmvers CGI
2.46
$ perl5.00404 -S pmvers CGI
2.42
$ devperl -S pmvers CGI
2.46
=========================================================
pmdesc - get a module description
$ pmdesc IO::Dir
IO::Dir (1.03) - supply object methods for directory handles
=========================================================
pmall - get all installed modules pmdesc descriptions
$ pmall
Pod::Html (1.01) - module to convert pod files to HTML
Config - access Perl configuration information
DB_File (1.61) - Perl5 access to Berkeley DB
DynaLoader (1.03) - Dynamically load C libraries into Perl code
Fcntl (1.03) - load the C Fcntl.h defines
File::Basename (2.6) - split a pathname into pieces
(etc)
This one is a bit crufty. It takes some options.
Check out the source.
=========================================================
pmdirs - print the perl module path, newline separated
$ 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
.
$ 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
.
=========================================================
plxload - show what files a given program loads at compile time
$ plxload perldoc
/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
$ plxload /usr/src/perl5.005_54/installhtml
/usr/local/devperl/lib/5.00554/Carp.pm
/usr/local/devperl/lib/5.00554/Exporter.pm
/usr/local/devperl/lib/5.00554/auto/Getopt/Long/autosplit.ix
/usr/local/devperl/lib/5.00554/strict.pm
/usr/local/devperl/lib/5.00554/vars.pm
/usr/local/devperl/lib/5.00554/Pod/Functions.pm
/usr/local/devperl/lib/5.00554/Getopt/Long.pm
/usr/local/devperl/lib/5.00554/i686-linux/Config.pm
/usr/local/devperl/lib/5.00554/lib.pm
/home/tchrist/perllib/Pod/Html.pm
/usr/local/devperl/lib/5.00554/Cwd.pm
/usr/local/devperl/lib/5.00554/AutoLoader.pm
=========================================================
pmload - show what files a given module loads at compile time
$ 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::File` | wc -l
3131
$ 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
=========================================================
pmexp - show a module's exports
$ 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
=========================================================
pminst - find what's installed
$ 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)
$ perl5.00404 -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
=========================================================
pmeth - list a class's methods, recursively
$ 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
You might want to send that through grep or grep -v looking
for "via" or "overridden".
=========================================================
pmls - long list the module path
$ pmls CGI
-r--r--r-- 1 root root 190901 Dec 6 03:19
/usr/local/devperl/lib/5.00554/CGI.pm
This is mostly here for people too lazy to type
$ ls -l `pmpath CGI`
=========================================================
pmcat - cat the module source through your pager
$ pmcat CGI
This is mostly here for people too lazy to type
$ more `pmpath CGI`
=========================================================
pman - show the module's pod docs
$ pman CGI
$ pman Curses
This is mostly here for people too lazy to type
$ pod2text `pmpath CGI` | more
=========================================================
pmfunc - show a function source code from a module
$ pmfunc Cwd::getcwd
sub getcwd
{
abs_path('.');
}
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`
=========================================================
podgrep - grep in pods of a file
Flags:
-i means case insensitive match
-p means page output
-f means format output
-h means check for matches in pod =head and =item headers alone,
and to keep printing podagraphs until the next header is found.
$ 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".)
=========================================================
pfcat - show pods from perlfunc
(uses podgrep, uses those options)
$ pfcat seek
is like
$ podgrep -h seek `podpath perlfunc`
Whereas
$ pfcat -pf seek
is like
$ podgrep -pfh seek `podpath perlfunc`
which is like
$ podgrep -h seek `podpath perlfunc` | podtext | $PAGER +/seek
=========================================================
podtoc - list table of contents of a podpage
$ 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)
=========================================================
podpath - show full path of pod file
(like pmpath, but works on standard manpages, too)
$ podpath Cwd
/usr/local/devperl/lib/5.00554/Cwd.pm
$ 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
=========================================================
pods - list all standard pods and module pods
$ pods
=========================================================
sitepods - list only pods in site_perl directories
$ 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
=========================================================
basepods - list only normal "man-page" style pods
$ 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
=========================================================
faqpods - list only faq pods
=========================================================
modpods - all module pods, including site_perl ones
=========================================================
stdpods - list standard pods, not site_perl ones
--
"I'd rather have :rofix than const."
--Dennis Ritchie
------------------------------
Date: Sun, 02 May 1999 16:13:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: E-Mail Attachments
Message-Id: <372CDBFC.C72BDEEF@mail.cor.epa.gov>
John J. Straumann wrote:
>
> Hey All:
>
> I am sending mail via a PERL script that looks like this:
>
> open ( MAIL, "| /usr/lib/sendmail -t");
> print MAIL "Subject: Whatever\n";
> print MAIL "From: $me\n";
> print MAIL "To: $eMail\n";
> print MAIL "Reply-To: $me\n";
> print MAIL "Text Content ";
> close ( MAIL );
>
> Can anyone give me an example of how to attach an .exe file?
>
> I tried it like this:
>
> open ( MAIL, "| /usr/lib/sendmail -t");
> print MAIL "Subject: Whatever\n";
> print MAIL "From: $me\n";
> print MAIL "To: $eMail\n";
> print MAIL "Reply-To: $me\n";
> print MAIL "MIME-Version: 1.0\n";
> print MAIL "X-Accept-Language: en\n";
> print MAIL "Content-Type: multipart/mixed;\n";
> print MAIL "Content-Type: application/octet-stream; name=$file\n";
> print MAIL "Content-Transfer-Encoding: base64\n";
> print MAIL "Content-Disposition: attachment; filename=$file\n";
> print MAIL "Text Content";
> close ( MAIL );
>
> but no joy...
You might have better luck if you try doing this using the MIME
modules available at CPAN. MIME::Base64 (en|de)codes base64
strings. And MIME::Lite should solve your attachment problem.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Sun, 02 May 1999 15:10:46 -0700
From: Daniel <dbohling@earthlink.net>
Subject: for ($i = 0, $i <= 29470, $i++} -- 29470 too high?
Message-Id: <372CCD66.E87FB8A5@earthlink.net>
Hi all, I am having a strange problem with the following for loop:
---------------------------------------------------
#!/usr/bin/perl -w
$i = 0;
my @new;
open (ZIPS, "</root/zips.txt") || die "$!\n";
while (@zips = <ZIPS>) {
push(@new,@zips);
}
close ZIPS;
$a = @new;
print "$a\n";
for ($i = 0, $i <= 29470, $i++) {
$new[$i] =~ tr/"/'/;
print "$new[$i]\n";
}
print $new[3];
print $new[4];
print $new[29469];
#open (NEW, >"/root/newzips.txt") || die "$!\n";
---------------------------------------------
When i run this script (it reads from a very large text file to be
inputted into a database), it gets to the third element of the @new
array and then exits. I originally had the test expression set to $i <=
@new, and it exhibited the same behaviour. I set it manually to 29740
'cuz that's the length of the array. Is the test expression too large or
is there something else causing 2 to be equal to 29470?
Thank you in advance for any info you might have on this... gonna
try something else in the meantime foreach i think. Thanks
Daniel Bohling
------------------------------
Date: Sun, 2 May 1999 14:09:53 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: for ($i = 0, $i <= 29470, $i++} -- 29470 too high?
Message-Id: <hd4ig7.sf1.ln@magna.metronet.com>
Daniel (dbohling@earthlink.net) wrote:
: Hi all, I am having a strange problem with the following for loop:
: ---------------------------------------------------
: #!/usr/bin/perl -w
: $i = 0;
: my @new;
: open (ZIPS, "</root/zips.txt") || die "$!\n";
: while (@zips = <ZIPS>) {
Read all of the lines (since you have provided list context there)
into @zips on the first loop iteration, and then exit the loop.
Having a loop that is guaranteed to always execute exactly
one time seems rather pointless.
: push(@new,@zips);
Then copy the saved up lines to another array.
Why not just put them into the @new array from the gitgo?
: }
: close ZIPS;
You can lose the loop and get all of the lines into @new with
1 line of code and no temporary variable:
@new = <ZIPS>;
: $a = @new;
: print "$a\n";
So $a now contains the number of elements in the @new array.
: for ($i = 0, $i <= 29470, $i++) {
1) that is not the correct syntax for the for loop.
you want semicolons, not commas there.
2) if $a is 29470, then you have elements 0 .. 29469 in the array.
So you want,
for ($i = 0; $i < @new; $i++) {
or
for ($i = 0; $i <= $#new; $i++) {
: When i run this script (it reads from a very large text file to be
: inputted into a database),
30,000 lines is not "very large" in my book.
'spose it depends on what you're used to though...
: it gets to the third element of the @new
: array and then exits.
You could have found this out for yourself if you could have
been troubled to copy that line to its own Perl script:
-----------
#!/usr/bin/perl -w
use strict;
my $i;
for ($i = 0, $i <= 29470, $i++) {
print "$_\n";
}
-----------
The output from that might have helped see what was going on...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 02 May 1999 23:35:18 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: for ($i = 0, $i <= 29470, $i++} -- 29470 too high?
Message-Id: <372CE0D7.94742596@home.com>
[posted & mailed]
Daniel wrote:
>
> Hi all, I am having a strange problem with the following for loop:
>
> ---------------------------------------------------
>
> #!/usr/bin/perl -w
Good.
> $i = 0;
> my @new;
> open (ZIPS, "</root/zips.txt") || die "$!\n";
Good.
> while (@zips = <ZIPS>) {
Yikes! That probably doesn't do what you think it does.
@zips = <ZIPS>;
will read the entire file and put one line in each element of @zips.
The while loop serves no purpose here unless rewritten (see below).
> push(@new,@zips);
> }
> close ZIPS;
> $a = @new;
> print "$a\n";
> for ($i = 0, $i <= 29470, $i++) {
for is a synonym for foreach and expects a list. You are providing a
list of 3 items here. If you want a C-style for loop then separate the
items with semi-colons.
for ($i = 0; $i <= 29470; $i++) {
> $new[$i] =~ tr/"/'/;
> print "$new[$i]\n";
> }
There is no need to read the file into an array to do your processing.
This would be much more efficient:
while ($zip = <ZIPS>) {
$zip =~ tr/"/'/;
print NEW $zip;
}
This can be cleaned up by using the default $_:
while (<ZIPS>) {
tr/"/'/;
print NEW;
}
Or run from a shell:
$ perl -pe tr/\"/\'/ zips.txt > newzips.txt
Or without perl at all:
$ tr \" \' < zips.txt > newzips.txt
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 2 May 1999 23:55:45 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Frequent Posters... gurus. I will regret this post I'm sure.
Message-Id: <Pine.HPP.3.95a.990502182352.24231E-100000@hpplus01.cern.ch>
On Sun, 2 May 1999, Charles R. Thompson wrote:
> Has anyone every actually considered a *focused* newsgroup for
> developers who use Perl for their website development language?
I suppose the moderated group just exists for decoration.
> a catch all. It looks like 'this is where I ask miscellaneous
> questions about Perl'.
But they don't. They come here and ask questions about miscellaneous
applications. That just happen to be programmed in the Perl language,
but the questions aren't about the Perl language.
If you speak English, would you therefore ask your specialist questions
about brainsurgery in the sci.lang.english newsgroup?
> 2) Going to authoring.cgi is practically useless because you get
> thrown in with the javascripters,
Oh, purrrlease. Presumably the comp.lang.javascript group is for
discussing tea-making?
------------------------------
Date: Sun, 2 May 1999 13:45:16 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP! - perl script won't write?!?
Message-Id: <cv2ig7.oe1.ln@magna.metronet.com>
Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote:
: On 2 May 1999 18:28:36 GMT, Bpcorbray <bpcorbray@aol.com> wrote:
: >
: >#!/usr/local/bin/perl
: Well you missed the -w. A bad sign to start with. Always enable warnings,
: especially if something isn't working.
: >
: >read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
: Why are you doing this yourself....?
I stopped reading after seeing those two things.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 02 May 1999 22:15:12 GMT
From: frankr@darbygroup.com
Subject: looking for ping time collector
Message-Id: <7giipf$il5$1@nnrp1.dejanews.com>
Hi all. I am looking for a perl script that will run under NT that will
collect ping response times from the sites in my wan periodically. I also
need to store the data for analysis and dump the analysis to html. Anyone
know where i should start?
Frank
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 2 May 1999 22:39:11 GMT
From: lbartels@pressenter.com (Lyndon F. Bartels)
Subject: Need help creating Date arrays
Message-Id: <7gik6f$pr6$1@jair.pressenter.com>
Hello,
I've done a lot of programming in many languages, but I'm a little rusty,
and Perl is different. I know what I want to do, but not sure how.
I'm working on a perl script that builds html pages, these pages are
essentially a directory
of all files in a given directory.
But with a twist.
First, there are a lot of files in a directory that have been accumulating
over the last
couple years. And more files are being added all the time. Occasionally, files
are moved in
and out of this directory.
Second, I want to have an "index.html" file for this directory. But I also
want to create sub pages
that have, on a month by month basis, links to files in the directory that
were created in that particular
month.
So for example. Since it is the beginning of May 1999, there will be an
index.html file with links
on it for all files (except html files) that have been added since May 1st
1999, but before June 1st, 1999.
Also, there will be links to archive sub-index pages for april 1999, march
1999, etc all the way back to
January of 1997. When this project started. Then next month, it'll be June's
files, and May's references will be
a on an "archive" page. On the Aprill 1999 sub-index file, there will be links
to all the files in the directory that
were created in April of 1999.
This way, I have a list of recent files, on the index file, but also a good
organization of older "archive" files as well.
First, I guess, I need to build an array of months from January 1997 to today.
I need to be able to build
this array, at least once, in the program, so I can use it later. This array
needs to be structured so I can compare
dates, and times against it. Something along the lines of the first day of
each month from january 1st 1997,
through the current month and year, and maybe also the first of next month.
Second, I need to use that array to build all the sub pages. In a loop
stucture, I need to build that loop so that it
creates each sub-page, with proper headings etc. And gets it ready to add
links.
Third, I need to loop through all the files in the directory. For each file,
I need to figure out the file's creation date, then add it to the page it
needs to be one.
Fourth, once the directory is scanned, and all the links built, on all the
pages, I need to loop through all the pages again,
this time, putting all the proper closing html tags-n-such on them, and then
closing the files.
Is there a way to do two dimensional arrays? I'd like to build columns on each
page, reading left to right. I need to
keep track which column, or table field, I'm currently writing to in each
file.
I thought of simple putting these in some database, and searching from that.
But I don't believe in that. These
directories are changed/updated once or twice a day. They don't need instant
data accuracy. If I could build the pages
once a day, I'd have faster downloads later.
Any ideas? Thoughts, sample code?
Thanks in advance,
Lyndon
------------------------------
Date: Sun, 2 May 1999 22:54:17 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: perl and C
Message-Id: <ebohlmanFB4nMH.DDt@netcom.com>
Akshat Bhargava <akshat@cs.utexas.edu> wrote:
: I have a perl script running as a "wwwuser". I need that script to
: communicate
: with a script in C. Basically, I have to pass an array from my perl
: script to my C script,
: and both have wwwuser priveleges so they cannot write files! Please
: help!!
Well, it sure sounds to me like you've got an interprocess communication
problem, so I should think your first step ought to be checking out what
Perl's documentation says about interprocess communication, wouldn't you
agree? What Perl's documentation has to say about IPC can be found,
believe it or not, in the perlipc (man page | HTML document | POD file)
that came with your Perl distribution.
------------------------------
Date: Sun, 2 May 1999 15:00:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: RegEx for matching Mbx "From " delimeter
Message-Id: <MPG.11966aea481fa50f989998@nntp.hpl.hp.com>
In article <7gigdm$c45$1@news.NERO.NET> on 2 May 1999 21:34:46 GMT, John
Stanley <stanley@skyking.OCE.ORST.EDU> says...
> In article <1dr4kbj.p02djv49sz3aN@[207.60.170.250]>,
> Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> >I think you would want to do this in separate steps. Find the From line
> >first, then parse out the pieces...
>
> Just as easy to do it in one pass.
>
> do {
> #start of new message
> $sender = $1;
> $date = $2;
> ...
> } if /^From\s+(\S+)\s+(.+)/;
Front-to-back, and with less copying:
if (($sender, $date) = /^From\s+(\S+)\s+(.+)/) {
#start of new message
...
}
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 02 May 1999 15:07:23 -0700
From: Yuriy Tenenbaum <yuriyt@ix.netcom.com>
Subject: simple CGI program
Message-Id: <372CCC9B.6EA81641@ix.netcom.com>
Hi,
Does anyone have a simple CGI program they can share. Something like a
simple searching engine of your database through the internet.
I would appreciate any help,
Sergey
------------------------------
Date: 2 May 1999 22:13:39 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: simple CGI program
Message-Id: <slrn7ipjgj.9gh.sholden@pgrad.cs.usyd.edu.au>
Yuriy Tenenbaum <yuriyt@ix.netcom.com> wrote:
>Hi,
>
>Does anyone have a simple CGI program they can share. Something like a
>simple searching engine of your database through the internet.
>
#!/usr/bin/perl -w
print "Content-type: text/plain\n\n";
print "Hello World!";
Doesn't access a database, but it's a pretty simple CGI program.
--
Sam
comments on data are usually much more helpful than on algorithms
--Rob Pike
------------------------------
Date: 2 May 1999 17:28:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Throw a person a fish...
Message-Id: <372cdfbb@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
David Cassell <cassell@mail.cor.epa.gov> writes:
:since I've supposedly been nicer and more helpful than
:some others here lately,
Give it time. You'll turn on them yet. Just watch.
--tom
--
The X server has to be the biggest program I've ever seen that doesn't
do anything for you. --Ken Thompson
------------------------------
Date: 2 May 1999 17:28:12 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: unos problemitas
Message-Id: <372cdf8c@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
David Cassell <cassell@mail.cor.epa.gov> writes:
:As well as Ahnold-speak [from Terminator 2], and probably half a
:dozen other pop-culture refs [and/or riffs].
When my pop grows a culture, I throw it away undrunk.
--tom
--
The secretaries don't understand me. --Rob Pike
------------------------------
Date: Sun, 02 May 1999 22:28:17 GMT
From: Mitch <portboy@home.com>
Subject: Using serial console as input/output on multiple serial connections...HELP!
Message-Id: <372CD1F1.7E8B906E@home.com>
Okay, I have set my code up so that when the machine comes up, it
automatically loads my script. However, the user cannot access the
script commands unless they plug into the serial console. Here's how I
have my code setup to do this:
$in = shift;
if ($in =~ "local")
{
$tty = "/dev/tty";
} else {
$tty = "/dev/tty00";
}
open(STDOUT, ">$tty");
open(STDERR, ">/dev/null");
open(STDIN, "<$tty");
Now, assuming there are two serial outputs on the given box, how can I
set the code up so that the user can plug into one serial console, run
some commands, and then plug into (or already be plugged into) the other
serial console and see the same changes that were made on the other
serial console? The console needs to work as though it were one
console. Whether plugged one serial console or the other, any updates
or changes need to be on both consoles, is this possible?
Any and all help is appreciated,
Mitch
------------------------------
Date: Sun, 02 May 1999 18:48:21 -0400
From: Frank Hale <frankhale@worldnet.att.net>
Subject: writing binary file
Message-Id: <372CD635.3383BF10@worldnet.att.net>
How do you write a binary file in Perl?
--
From: Frank Hale
Email: frankhale@linuxstart.com
------------------------------
Date: 2 May 1999 17:32:15 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: writing binary file
Message-Id: <372ce07f@cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Frank Hale <frankhale@worldnet.att.net> writes:
:How do you write a binary file in Perl?
1. Install an operating system.
2. Open the file.
3. Write.
--tom
--
Basically, avoid comments. If your code needs a comment to be understood,
it would be better to rewrite it so it's easier to understand. --Rob Pike
------------------------------
Date: Sun, 02 May 1999 23:40:04 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: writing binary file
Message-Id: <372CE1FE.5B553871@home.com>
Frank Hale wrote:
>
> How do you write a binary file in Perl?
#!/usr/local/bin/perl -w
format STDOUT =
a binary file
.
write
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Sun, 02 May 1999 19:55:14 -0400
From: Frank Hale <frankhale@worldnet.att.net>
Subject: writing binary files in Perl
Message-Id: <372CE5E2.C7990EFE@worldnet.att.net>
Okay since my last question wasn't clear.
I want to write data to a file in binary using Perl. I don't want to
produce a text file but have a binary file, like how an executable file
would be stored.
I am writing an assembler in Perl so this should clarify the type of
file I need to write.
This method produces a text file.
open (BIN, ">binary.dat");
print BIN @binary_data;
close BIN;
--
From: Frank Hale
Email: frankhale@worldnet.att.net
------------------------------
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 5545
**************************************