[8528] in Perl-Users-Digest
Perl-Users Digest, Issue: 2145 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 20 14:18:42 1998
Date: Fri, 20 Mar 98 11:00:47 -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 Fri, 20 Mar 1998 Volume: 8 Number: 2145
Today's topics:
Re: A Perl version of Crypt <rkoehler@osmre.gov>
Can't understand /g (match global) operator - help! brosser@gil.com.au
Re: Can't understand /g (match global) operator - help! (Kevin B Cohen)
Re: CGI script failing...asking for hint re: error msg (William Burrow)
chdir in win32 dgriffith2@bender.com
Re: dis gotta be a easy one?!?!?! (Ronald L. Parker)
Re: display lines <cstewart@flash.net>
Error building perl on VMS 5.5-2 and some questions... (Brian Wheeler)
Evaluate expression inside print "" <trachier@crrel.usace.army.mil>
Evaluate expression inside print "" <trachier@crrel.usace.army.mil>
Evaluate expression inside print "" <trachier@crrel.usace.army.mil>
Evaluate expression inside print "" <trachier@crrel.usace.army.mil>
FYI-Writing scrippts with TextPad <doug@ccinet.com>
Re: HELP ! Customized advertising in web pages <doug@weboneinc.net>
Re: HELP! strange problem with loop <j.kiser@ix.netcom.com>
Re: HELP! strange problem with loop <lsj@bnl.gov>
Re: How to take the icecream from the trashbox? schwern@starmedia.net
Re: ls -l to an array and pull 3 columns on data schwern@starmedia.net
Mail filter package? <marms@sandia.gov>
Re: Mail filter package? <woodard@kodak.com>
Re: Mail filter package? (Aaron B. Dossett)
Re: Objects: Effective communication among siblings? schwern@starmedia.net
Re: Opening dirs in Win32 (Ronald L. Parker)
Re: Opening dirs in Win32 <giles@agentware.com>
Re: Oraperl - Stored Procedures How to ?? (John D Groenveld)
Re: Perl Daemons <woodard@kodak.com>
PGP 2.6.2 command line xlat to PGP 5.0 (James B. Crigler)
Re: pRPC troubles <vandevegt@lucent.com>
sending mail through perl Francois_Bor@bde.espci.fr
Trouble with alarm when waiting on <INPUT> <langford@uiuc.edu>
Re: Wanted: email address gleaner (to use for 'good' no (Michael J Gebis)
Re: what is wrong with being a novice ?? <merlyn@stonehenge.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 20 Mar 1998 10:12:05 -0700
From: "Richard W. Koehler" <rkoehler@osmre.gov>
Subject: Re: A Perl version of Crypt
Message-Id: <6eu83m$8km@gargantubrain.osmre.gov>
Sneex wrote in message <35106783.CA258AAF@usa.net>...
>CRYPT is Built into Perl, no need to post it :-)
>
>HTH,
>Sneex :-)
Well, actually, that is not always the case. If using the ActiveState
pre-compiled Win32 port of Perl, yes it is.
If using Gurusamy Sarathy's port of Perl 5.004.004, also pre-compiled, the
crypt function was not included in the compile. If you attempt to use a
script which includes a reference to the crypt function, you get the
following diagnostic error message:
> (The crypt() function is unimplemented due to excessive paranoia.
>(F) Configure couldn't find the crypt() function on your machine, probably
because your vendor didn't supply it, >probably because they think the U.S.
Government thinks it's a secret, or at least that they will continue to
pretend >that it is. And if you quote me on that, I will deny it.
But, as mentioned elsewhere, you can get Crypt.pm and Crypt:DES etc from
CPAN. Good luck.
Rick Koehler, JAPH, or should I say JA-pilgrim-on-the-road-to-Perldom
(JAPOTRTP)
------------------------------
Date: Fri, 20 Mar 1998 11:21:59 -0600
From: brosser@gil.com.au
Subject: Can't understand /g (match global) operator - help!
Message-Id: <6eu8jg$i46$1@nnrp1.dejanews.com>
Hi. I've been writing a simple little lexical scanner
today, and 'discovered' how wonderful Perl's /g regexp
operator can be.
But, near the end of the project, I'm coming a cropper -
perl's not working the way I'd expect, so there must be
(many!) things I still don't understand. I'd like to list
two examples, and if someone could tell me how/why perl
does what it does I'd be grateful!
1. "abc" =~ /([abc])*/g gives (c, undef).
Why doesn't it match the 'a' first, then the 'b',
and then the 'c', giving (a,b,c)? And why the trailing
undef (in all cases where I've used parenthesis and /g)?
2. "aXa" =~ /(a)*/g gives (a, undef, a, undef)
which I guess I can understand - at least it's giving
me both 'a' tokens, although I still don't know why
the undefs come in. But
"aaaaaXa" =~ /(a)*/g also gives (a, undef, a, undef)
i.e. it's ignoring the multiple string of a's in the
first part.
Can someone be kind enough to discuss how this works, or poi
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: 20 Mar 1998 13:31:03 -0500
From: kcohen@julius.ling.ohio-state.edu (Kevin B Cohen)
Subject: Re: Can't understand /g (match global) operator - help!
Message-Id: <6eucl7$crn@julius.ling.ohio-state.edu>
>today, and 'discovered' how wonderful Perl's /g regexp
like tambourines and banjos, /g should be used sparingly. a really
good use for it is to control iteration through a loop, e.g.
while ($string =~ /[aeiou]/g) {
however, it might not really be what you want here.
>1. "abc" =~ /([abc])*/g gives (c, undef).
>
> Why doesn't it match the 'a' first, then the 'b',
> and then the 'c', giving (a,b,c)? And why the trailing
> undef (in all cases where I've used parenthesis and /g)?
my best guess here is that you're trying toj use the /g switch to get
functionality that you've already got with the *, i.e. trying to get
something to match more than once. if you just write
$string = "abc";
$string =~ /[abc]*/;
...then $& will hold "abc".
>2. "aXa" =~ /(a)*/g gives (a, undef, a, undef)
>
> which I guess I can understand - at least it's giving
> me both 'a' tokens, although I still don't know why
> the undefs come in. But
>
> "aaaaaXa" =~ /(a)*/g also gives (a, undef, a, undef)
>
> i.e. it's ignoring the multiple string of a's in the
> first part.
where is it "giving" this to? do you have a bunch of variables in a
list? are you putting stuff in an array? might be better to give
more of your code.
the best place i know of to get a grasp on the match operator and /g
is the friedl book ("mastering regular expressions"), pp. ... rats,
don't have it in front of me. look in the index for "match operator"
and "return values."
kev
------------------------------
Date: 20 Mar 1998 16:46:48 GMT
From: aa126@NOSPAM.fan.nb.ca (William Burrow)
Subject: Re: CGI script failing...asking for hint re: error msg
Message-Id: <slrn6h57bn.dfq.aa126@fan1.fan.nb.ca>
On 20 Mar 98 03:14:56 GMT, Alex Lane <alexlane@ghg.net> wrote:
>I have a RedHat Linux 4.2 box set up and am trying to run a cgi script
>written in Perl.
>
>An attempt is apparently being made to execute the script, but the
>following appears in the error_log file:
>
>exec of <script name and path> failed, errno is 2
><date/time> access to <script name and path> failed for <user>, reason:
>Premature end of script headers.
Either you aren't printing a header line, or you have a problem with
flushing. Make sure you are printing a header line as advised by several
others on the net first.
--
--
William Burrow, VE9WIL (Adv, 5wpm) -- New Brunswick, Canada
Copyright 1997 William Burrow
------------------------------
Date: Fri, 20 Mar 1998 13:33:47 -0500
From: dgriffith2@bender.com
Subject: chdir in win32
Message-Id: <3512B68B.721D@bender.com>
i'm using perl for win32 v5, the chdir function doesn't seem to work, no
matter what syntax i use it will not change the dir out of
c:\inetpub\wwwroot
any ideas?
...pls forgive my newbie-ism
djg
------------------------------
Date: Fri, 20 Mar 1998 17:03:31 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: dis gotta be a easy one?!?!?!
Message-Id: <3512a0b5.14753063@10.0.2.33>
On Fri, 20 Mar 1998 12:02:23 GMT, Sneex
<chasecreek.systemhouse@usa.net> wrote:
>First you, need to create better Subject Lines...
>(I almost passed this up...)
>
>I am curious, you have access to the cgi-bin on a server via
>FTP ONLY? Is it in your personal directory?
This is common practice for a number of webspace-only providers.
The simple solution is, use CGI.pm so it can be tested from the
command line, and install Perl on your home machine. If this is
impractical because the script uses a Unix database or Unix-only
features like forking, then install Linux, FreeBSD, or the like, or
resort to testing it on the web server.
------------------------------
Date: 20 Mar 1998 17:03:36 GMT
From: "chuck" <cstewart@flash.net>
Subject: Re: display lines
Message-Id: <01bd541c$b6b3dc20$bd3a1ed1@flashnet.fwh.afres.af.mil>
This based upon search and seek with preserve, not what I needed. Thanks..
> You need to preserve state in the stateless HTTP protocol. Have a look
> at Randal Schwartz' WebTechniques column #2, where he discusses just
that:
>
------------------------------
Date: 20 Mar 1998 18:31:49 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Error building perl on VMS 5.5-2 and some questions...
Message-Id: <6eucml$p4f$1@jetsam.uits.indiana.edu>
After solving a pile of "out of memory" errors, I've got it to build miniperl
but I get an error before it completes:
MCR Sys$Disk:[]miniperl.exe "-I[.lib]" [.vms]gen_shrfls.pl -f gen_shrfls.opt
no UTC offset information; assuming local time is UTC.
Insecure $ENV{PATH} while running with -T switch at [.vms]gen_shrfls.pl line 59.
%SYSTEM-F-NOLOGNAM, no logical name match
%MMK-F-ERRUPD, error status %X000001BC occurred when updating target PERLSHR_XTR
AS.TS
Also, if I've got UCX installed, how to I have perl use it?
Thanks!
Brian Wheeler
bdwheele@indiana.edu
------------------------------
Date: 20 Mar 98 12:29:07 -0500
From: "Gary Trachier" <trachier@crrel.usace.army.mil>
Subject: Evaluate expression inside print ""
Message-Id: <B138119C-BDB8D@144.3.128.40>
Hi Everyone,
I've been scratching my head over this one, and it is time to ask for
help. I want to evaluate an expression inside double-quotes of a
print statement. How can it be done?
Here is an example:
{
my $var =3D 5;
print "N plus one is ($var + 1)\n";
}
It should print out
N plus one is 6
Simple, right?
Thanks for your help.
-Gary
------------------------------
Date: 20 Mar 98 12:27:22 -0500
From: "Gary Trachier" <trachier@crrel.usace.army.mil>
Subject: Evaluate expression inside print ""
Message-Id: <B1381133-BC2C5@144.3.128.40>
Hi Everyone,
I've been scratching my head over this one, and it is time to ask for
help. I want to evaluate an expression inside double-quotes of a
print statement. How can it be done?
Here is an example:
{
my $var =3D 5;
print "N plus one is ($var + 1)\n";
}
It should print out
N plus one is 6
Simple, right?
Thanks for your help.
-Gary
------------------------------
Date: 20 Mar 98 12:33:08 -0500
From: "Gary Trachier" <trachier@crrel.usace.army.mil>
Subject: Evaluate expression inside print ""
Message-Id: <B138128C-C13E6@144.3.128.40>
Hi Everyone,
I've been scratching my head over this one, and it is time to ask for help.
I want to evaluate an expression inside double-quotes of a print
statement. How can it be done?
Here is an example:
{
my $var = 5;
print "N plus one is ($var + 1)\n";
}
It should print out
N plus one is 6
Simple, right?
Thanks for your help.
-Gary
------------------------------
Date: 20 Mar 98 12:44:29 -0500
From: "Gary Trachier" <trachier@crrel.usace.army.mil>
Subject: Evaluate expression inside print ""
Message-Id: <B1381535-CB3D5@144.3.128.40>
Hi Everyone,
I've been scratching my head over this one, and it is time to ask for help.
I want to evaluate an expression inside double-quotes of a print
statement. How can it be done?
Here is an example:
{
my $var = 5;
print "N plus one is ($var + 1)\n";
}
It should print out
N plus one is 6
Simple, right?
Thanks for your help.
-Gary
------------------------------
Date: Fri, 20 Mar 1998 18:07:08 GMT
From: "Doug Evans" <doug@ccinet.com>
Subject: FYI-Writing scrippts with TextPad
Message-Id: <gfyQ.12$tP5.158954@katana>
>From a experience...-:)
If you are going to write scripts with Text Pad, make sure that you set the
configuration to...
1. Remove trailing spaces, when saving, and...
2. Automatically terminate the last lineof the file
Doug
------------------------------
Date: Fri, 20 Mar 1998 12:39:48 -0500
From: Douglas Clifton <doug@weboneinc.net>
Subject: Re: HELP ! Customized advertising in web pages
Message-Id: <3512A9E4.2D85349F@weboneinc.net>
Olivier ROSENTHAL wrote:
>
> I have a web site to build and I would need explanations on how to include a
> customized advertising banner on the top of the page. I would like this
> banner to depend on the client carateristics (computer, country, search in a
> search engine, etc.).
What the *&#% does this have to do w/ Perl?
--
Douglas Clifton
Unix/C/Perl/CGI/HTML Programmer
doug@weboneinc.com
------------------------------
Date: Fri, 20 Mar 1998 09:04:16 -0800
From: Jeffee Kiser <j.kiser@ix.netcom.com>
Subject: Re: HELP! strange problem with loop
Message-Id: <3512A190.BAF@ix.netcom.com>
Lance wrote:
>
> Hi,
> I have a strange problem, well, maybe a dumb one.
> I'm trying to use a loop like this:
>
> #!/usr/local/bin/perl -w
> $var3=1.9; # line A
> while ($var3 >= 0) {
> print "\$var3=$var3\n";
> if ($var3 <= 0.1) { # line B
> print "plonk x1=$var3\n"; # line C
> }
> $var3 = $var3 - 0.2;
> }
>
> If I use this program, line C is not printed, which means
> it doesn't go into the IF block. Whereas I simply change
> line A into $var3=0.9, and line C is printed! Or if I change
> line B to if ($var3 le 0.1), line C is printed as well(no matter
> what value is assigned to $var3 in line A)!
>
> Is this some kind of bug or there's something basic that I'm
> missing? Any advice will be appreciated!
>
> --
> Regards,
> Lance J.
Anytime you are dealing with floats in a loop there is potential harm.
If you were to look at what is going on more deeply by replacing the
first print statement with this:
printf("\$var3=%.16f\n", $var3);
Where you think $var3 is equal to 0.1 you would see that it is actually
equal to 0.1000000000000002 which will not satisfy the if block. One
solution to this that you may want to try is to replace the decrement
statement with the following:
$var3 = sprintf("%.1f", $var3-0.2);
This will serve as a "workaround" for the particular example that you
posted but I would still be cautious of the results that you can't see.
Unless, you are restricted in some way, my best suggestion would be to
multiply everything by 10 so that you would be operating on integers.
Jeff Kiser
Design Engineer -- San Jose, CA
------------------------------
Date: Fri, 20 Mar 1998 13:36:13 -0500
From: "Lance" <lsj@bnl.gov>
Subject: Re: HELP! strange problem with loop
Message-Id: <6eucv4$oe4$1@sun20.ccd.bnl.gov>
Problem solved. Thank you all+ACE- ... Lance
------------------------------
Date: Fri, 20 Mar 1998 12:31:44 -0600
From: schwern@starmedia.net
To: rossen@hikari-jhs.yamaguchi-u.ac.jp
Subject: Re: How to take the icecream from the trashbox?
Message-Id: <6euciv$okl$1@nnrp1.dejanews.com>
Look at the perlfunc man page and read about "split", and get yourself a copy
of Learning Perl, 2nd edition.
Or if you're blessed with perl 5.004, "perldoc -f split" from your shell will
tell you about split.
The perlre man page will also be of some future help.
In article <351276EF.305F3D56@hikari-jhs.yamaguchi-u.ac.jp>,
Rossen Mikhov <rossen@hikari-jhs.yamaguchi-u.ac.jp> wrote:
>
> Hello. I have a problem and I would very much appreciate an advice.
>
> I have a long string and I want to get only a part of it. This is my
> script
>
> #Start
> $trashbox =":trash:trash:chocolate-icecream:arrow:trash:trash:trash";
> #The location of the icecream is just behind the ':arrow'
> $icecream_only = #What?
> #End
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 20 Mar 1998 12:02:51 -0600
From: schwern@starmedia.net
To: hightowr@usa.net
Subject: Re: ls -l to an array and pull 3 columns on data
Message-Id: <6euasb$m66$1@nnrp1.dejanews.com>
I did some benchmarking...
#!/usr/bin/perl -w
use Benchmark;
$dir = '/usr/bin';
timethese ( 50, {
'readdir' => q'opendir DIR, $dir || die $!;
@files = map { [(stat("$dir/$_"), "$dir/$_")]}
readdir DIR;',
'system' => q'@array = map { chomp; [split /\s+/] }
`ls -l $dir | cut -f1,2,3`;
shift @array; # Dump the "total" line.
'
}
);
print "Readdir:\t", scalar @files, "\n";
print "@{$files[2]}", "\n";
print "system:\t", scalar @array, "\n";
print "@{$array[2]}", "\n";
And I was very surprised at the results...
Benchmark: timing 50 iterations of readdir, system...
readdir: 24 secs ( 6.56 usr 14.65 sys = 21.21 cpu)
system: 21 secs ( 6.80 usr 0.32 sys + 9.01 cusr 3.22 csys = 19.35 cpu)
Readdir: 1059
773 4081 16877 2 0 0 0 5120 890373724 887033150 887033150 /usr/bin/X11
system: 1057
-r-xr-xr-x 1 root root 13609 Feb 9 19:46 HEAD
(Note, @files has two more elements in it than @array because readdir()
returns . and .. whereas ls -l doesn't (not on my machine, anyway) )
So it would -appear- that ls -l is a bit faster. But... lets examine this a
bit closer.
1) The timing difference is a trivial amount considering the number of tries
(50) and the number of files (1000+) it iterated over.
2) cut -f1,2,3 didn't work. I don't know if it works on your system, but it
doesn't on mine (RH5). Which brings us immediately up to the core issue:
readdir is cross-platform, `ls -l` is NOT. Try `ls -l` on a Windows machine.
Try it on a Mac. What if ls isn't in $ENV{PATH}??? (Yes, this will happen if
you run in taint-mode. I usually set $ENV{PATH} = ''; out of habit.)
3) ls -l returns information in a human-readable format, but its not very
usable to a program. -r-xr-xr-x has to be translated into 0555 somehow.
"root" has to be translated into 0. "Feb 9 19:46" has to be translated into a
unix time, etc... doing all that will blow your efficiencies out the window.
When I add in -just- the translation from user and group name to uid and
gid...
Benchmark: timing 50 iterations of readdir, system...
readdir: 22 secs ( 6.87 usr 14.45 sys = 21.32 cpu)
system: 45 secs (15.13 usr 15.90 sys + 9.20 cusr 2.89 csys = 43.12 cpu)
So much for efficiency.
4) stat returns alot more information than ls -l. In fact, it gives you just
about -all- available information about the file. How do you get the last
access time from ls -l?
So there ya go. Use readdir, not `ls -l`.
In article <3510A3A7.25F28629@probe.net>,
hightowr@usa.net wrote:
>
> schwern@starmedia.net wrote:
>
> > Avoid unnecessary system calls. Use readdir, opendir and stat.
> >
> > opendir(DIR, $dirname) || die $!;
> > foreach my $filename (readdir(DIR)) {
> > @stat = stat $filename;
> > # do something with @stat...
> > }
> >
> > stat returns everything that ls -l does, and more and in a consistant
format.
>
> Hmmmm. Why?
>
> I would do something like
>
> chomp(@array = `ls -l | cut -f1,2,3`)
>
> Is that less efficient? Obviously it not true perl-ese, but which is fas
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 20 Mar 1998 10:01:20 -0700
From: Mike Arms <marms@sandia.gov>
Subject: Mail filter package?
Message-Id: <3512A0E0.2096@sandia.gov>
Being a typical lazy Perl programmer :-) I am looking for
a Mail filter package. I need it to be able to extract
mail messages from /var/mail/$USER that come from particular
mailing lists and append them to named subfolders.
Example:
%filter = (
'owner-ptk@lists.Stanford.EDU' => 'ptk',
'"Henry J. Cobb" <hcobb@io.com>' => 'ogre',
'JDCNewsLetter@web4.javasoft.com' => 'java',
'JDCTechTips@web4.javasoft.com' => 'java',
'majordom-afterstep-digest-owner@eosys.com' => 'afterstep',
);
Actually, I did write my own simple filter that does this,
but I can't help but think that someone out there has done
a better more full featured mail filter package. Nothing
pops up on the CPAN though.
Recommendations?
--
Mike Arms
marms@sandia.gov
When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
------------------------------
Date: Fri, 20 Mar 1998 12:32:56 -0500
From: Steve Woodard <woodard@kodak.com>
Subject: Re: Mail filter package?
Message-Id: <3512A848.6552@kodak.com>
Do a search for procmail on your favorite Web search engine.
Mike Arms wrote:
>
> Being a typical lazy Perl programmer :-) I am looking for
> a Mail filter package. I need it to be able to extract
> mail messages from /var/mail/$USER that come from particular
> mailing lists and append them to named subfolders.
>
> Example:
> %filter = (
> 'owner-ptk@lists.Stanford.EDU' => 'ptk',
> '"Henry J. Cobb" <hcobb@io.com>' => 'ogre',
> 'JDCNewsLetter@web4.javasoft.com' => 'java',
> 'JDCTechTips@web4.javasoft.com' => 'java',
> 'majordom-afterstep-digest-owner@eosys.com' => 'afterstep',
> );
>
> Actually, I did write my own simple filter that does this,
> but I can't help but think that someone out there has done
> a better more full featured mail filter package. Nothing
> pops up on the CPAN though.
>
> Recommendations?
>
> --
> Mike Arms
> marms@sandia.gov
> When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
--
Steve Woodard (716)-588-2069
Pager (716)-975-3984
Optical Storage Products 1/800/KP
Internet: woodard@kodak.com
------------------------------
Date: 20 Mar 1998 18:26:51 GMT
From: aarond@alpha.ewl.uky.edu (Aaron B. Dossett)
Subject: Re: Mail filter package?
Message-Id: <6eucdc$cjd$1@service3.uky.edu>
Mike Arms (marms@sandia.gov) wrote:
> Being a typical lazy Perl programmer :-) I am looking for
> a Mail filter package. I need it to be able to extract
> mail messages from /var/mail/$USER that come from particular
> mailing lists and append them to named subfolders.
>
Procmail is far and away the best tool for what you want to do.
ftp://ftp.fu-berlin.de/pub/unix/mail/procmail
--
Aaron B. Dossett | Finger aarond@london.cslab.uky.edu for PGP key
dossett@bigfoot.com|
Comp. Sci. Senior | http://www.ewl.uky.edu/~aarond
University of Kentucky 1996 NCAA Basketball Champions
------------------------------
Date: Fri, 20 Mar 1998 12:26:27 -0600
From: schwern@starmedia.net
To: rael@dnai.com
Subject: Re: Objects: Effective communication among siblings?
Message-Id: <6euc93$oad$1@nnrp1.dejanews.com>
Did you have a look at ObjectTemplate as described in chapter 8 of _Advanced
Perl Programming_? The module itself is available on CPAN as
http://www.perl.com/CPAN/modules/by-authors/id/SRIRAM/examples.tar.gz
This essentially stores objects in a series of arrays using a scalar reference
to an array element number to refer to them rather than the typical hash
reference. Saves lots of memory, too.
Or, you could do something like this:
package HappyFamily;
my %family;
sub new (
my($proto, $name, @args) = @_;
# do the usual $proto to $class stuff and $self = {}...
$self->{'name'} = $name;
bless $class, $self;
$family{$name} = $self;
}
# $brother = $obj->wheresYourBrother($name);
sub wheresYourBrother {
my($self, $name) = @_;
return $family{$name};
}
# @result = $obj->getYourBrotherToDoIt($name, 'clean', @room);
sub getYourBrotherToDoIt {
my($self, $name, $method, @args) = @_;
my $brother = $self->wheresYourBrother($name) || return undef;
my $brotherMeth = $brother->can{$method} || return undef;
return &$brotherMeth($brother, @args);
}
1;
Have your objects inherit from something like this. (You'll have to tweek the
new() method to get it to inherit properly)
In article <6esc7r$i14$1@castor.dnai.com>,
"Rael Dornfest" <rael@dnai.com> wrote:
>
> Hi Folks,
>
> I've performed a fairly comprehensive scan of the Perl books, FAQs, MAN
> Pages, and newsgroups but can't seem to find much on the topic of an
> object referencing its siblings. What I mean is...
>
> I have an array of objects -- let's call it @array_of_objects.
> I want each object to be able to communicate with its siblings -- in
> other words, I want $array_of_objects[0] to be able to talk to a method
> lookup() in $array_of_objects[1] and vice-versa.
>
> Is there a snazzier method than passing in a reference to the
> array @array_of_objects?
>
> Any help would be greatly appreciated.
>
> Rael
>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 20 Mar 1998 17:06:51 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: Opening dirs in Win32
Message-Id: <3513a1a5.14993249@10.0.2.33>
[posted and emailed]
On Thu, 19 Mar 1998 20:54:32 -0800, "Beau Giles" <giles@agentware.com>
wrote:
>I've got an odd little bug that's hit me in porting a cgi script from Unix
>to Windows. I've got a variable passed through STDIN representing a
>directory in a file system ($PWD).
>
>I've massaged it with the following lines:
>
>$PWD =~ s/%3A/:/g;
>$PWD =~ s/%5C/\\/g;
>
>to replace the substitution done by passing through post. A test value I
>passed in was "C:\temp" and checking afterward by printing the value, that's
>what I see. However if I do
>
>$foo = ($PWD eq "C:\\tmp") ? "yes" : "no";
(I assume the missing 'e' is a mistake.) Is there a possibility your
directory name contains whitespace? Try
$PWD =~ s/\s+//g;
and see what happens.
------------------------------
Date: Fri, 20 Mar 1998 09:38:58 -0800
From: "Beau Giles" <giles@agentware.com>
Subject: Re: Opening dirs in Win32
Message-Id: <6eu9lp$29c$1@owl.slip.net>
Thanks for the help, that fixed it.
-- Beau Giles
Ronald L. Parker wrote in message <3513a1a5.14993249@10.0.2.33>...
>[posted and emailed]
>
>On Thu, 19 Mar 1998 20:54:32 -0800, "Beau Giles" <giles@agentware.com>
>wrote:
>
>>I've got an odd little bug that's hit me in porting a cgi script from Unix
>>to Windows. I've got a variable passed through STDIN representing a
>>directory in a file system ($PWD).
>>
>>I've massaged it with the following lines:
>>
>>$PWD =~ s/%3A/:/g;
>>$PWD =~ s/%5C/\\/g;
>>
>>to replace the substitution done by passing through post. A test value I
>>passed in was "C:\temp" and checking afterward by printing the value,
that's
>>what I see. However if I do
>>
>>$foo = ($PWD eq "C:\\tmp") ? "yes" : "no";
>
>(I assume the missing 'e' is a mistake.) Is there a possibility your
>directory name contains whitespace? Try
>
>$PWD =~ s/\s+//g;
>
>and see what happens.
>
------------------------------
Date: 20 Mar 1998 13:02:37 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Oraperl - Stored Procedures How to ??
Message-Id: <6euavt$3rd$1@tholian.cse.psu.edu>
In article <3511D95C.2E9B@cisco.com>,
Bhanu Sutraye <psutraye@cisco.com> wrote:
>I have problems with stored procedures/functions.
Upgrade to perl5.004_04, DBI, DBD::Oracle and use the Oraperl emulation
module. Examples with stored procedures are included.
http://www.perl.org/CPAN/modules/00modlist.long.html
Happy Perl'ng
John
groenveld@acm.org
------------------------------
Date: Fri, 20 Mar 1998 12:54:55 -0500
From: Steve Woodard <woodard@kodak.com>
Subject: Re: Perl Daemons
Message-Id: <3512AD6F.382@kodak.com>
The act of turning your perl script into a binary isn't what makes it a
daemon. Many of the daemons running on a unix box are shell scripts.
Take a look at the /etc/rc2.d directory. I know that volmgt for sure is
a shell script. If you write your perl script correctly it can be a
daemon WITHOUT turning it into a binary. If you put your perl script in
the proper /etc/rc?.d directory, and name it correctly, the daemon will
get kicked off when the machine boots. Your sys-admin won't be too
happy with you if your daemon doesn't behave well though....
Stop by your local book store and thumb through "Perl 5 How-To" (a Waite
Group publication). It gives a very good basic daemon course with a
perl example of how to write a well behaved daemon.
Mark Kucera wrote:
>
> this program to compile perl, is it the perl2exe utility? if so is
> there something for unix compilation?
>
> mark
--
Steve Woodard (716)-588-2069
Pager (716)-975-3984
Optical Storage Products 1/800/KP
Internet: woodard@kodak.com
------------------------------
Date: 20 Mar 1998 13:28:48 -0500
From: crigler@seo.com (James B. Crigler)
Subject: PGP 2.6.2 command line xlat to PGP 5.0
Message-Id: <lzbtv1qkrj.fsf@jim.seo.com>
Has anyone done a command line translation shell so I can use an
updated PGP within emacs mailcrypt? Or do I need to manufacture this
one myself?
--
Jim Crigler <crigler@seo.com>
Schwartz Electro-Optics, Inc. Voice: (407)298-1802 x200
3404 N. Orange Blossom Trl. Fax: (407)290-9666
Orlando FL 32804-3498 USA
------------------------------
Date: Fri, 20 Mar 1998 11:06:23 -0600
From: Jim VandeVegt <vandevegt@lucent.com>
Subject: Re: pRPC troubles
Message-Id: <3512A20F.2A8EBE76@lucent.com>
I am using Solaris 2.5.1 and 2.6 on Sun hardware. Would someone be able to
try my scripts in their environment to see if it works. pNETagent is
working beautifully, and it runs on top of pRPC, which is why I believe
there is something wrong with my simple RPC code included with the last
message.
Thanks.
Jim VandeVegt wrote:
> I am trying to get started with the pRPC package. I have read the
> documentation and have used a subset of the example given to attempt a
> test. I have also looked over the code for pNETagent, which is working
> great for my remote Informix connections.Thanks for any help.
Jim VandeVegtvandevegt@lucent.com
------------------------------
Date: Sat, 21 Mar 1998 03:08:03 GMT
From: Francois_Bor@bde.espci.fr
Subject: sending mail through perl
Message-Id: <6eub68$8ht$1@pinot.ext.jussieu.fr>
hello !
i would like to send amils through my perl program.
I have found in a book that i should make a pipe, so that i have done
it that way :
$filedemel = "| /bin/mailx -s "`cat subjectfile`" `cat tofile`";;
open (MAILE, $filedemel);
....
the trouble is that :
- i have to put " " after -s for the subjet ( cause mailx need it)
- but when the perl program meet this "", it think it is the end of
the one before : $findemel = "....,
so that it doesn't work.
i search a way to send a subject trough mailx in perl program. Could u
help me ?
thank u.
------------------------------
Date: Fri, 20 Mar 1998 11:24:05 -0600
From: Jacob Langford <langford@uiuc.edu>
Subject: Trouble with alarm when waiting on <INPUT>
Message-Id: <3512A634.600A9E4D@uiuc.edu>
Hi,
The alarm call doesn't seem to help when I'm waiting
on <INPUT> from a process.
The following code generates a list of 'pingable' machines.
I use the system command "ping" and always use the
function "alarm" to terminate the ping session. The program
hangs up on machines that don't respond, I presume because
alarm doesn't work when I'm waiting on <INPUT>.
Any ideas?
Jacob (langford@uiuc.edu)
---------------------------------------
#!/usr/bin/perl
local $SIG{ALRM} =
sub {
die "Stopping ping.";
};
for ($i=1; $i<256; $i++) {
$host = "128.174.135.$i";
eval {
open (PING, "ping $host |");
alarm 3;
$responses = 0;
while (<PING>) {
++$responses;
}
};
close (PING);
if ($responses > 1) {
print "$host ALIVE\n";
} else {
print "$host DEAD\n";
}
}
------------------------------
Date: 20 Mar 1998 17:55:11 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Wanted: email address gleaner (to use for 'good' not spam!)
Message-Id: <6euahv$657@mozo.cc.purdue.edu>
Jaime Metcher <metcher@spider.herston.uq.edu.au> writes:
}This is like asking for a recipe for plastic explosive. Sure, there are
}many and legitimate uses for plastique - but *nobody* in their right
}mind is going to tell you how to make the stuff on *Usenet*.
What do "right mind" and "Usenet" have to do with each other?
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: 20 Mar 1998 10:11:47 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: "Jon Marshall" <xkn14@dial.pipex.com>
Subject: Re: what is wrong with being a novice ??
Message-Id: <8c4t0twalo.fsf@gadget.cscaper.com>
>>>>> "Jon" == Jon Marshall <xkn14@dial.pipex.com> writes:
Jon> That said if someone really has made an effort and they simply don't get it
Jon> surely this should be one of the main places to go for an
Jon> explanation/answer - sure some of the questions will be basic and the
Jon> answer might be found in the FAQ or more likely the Camel book ,but if perl
Jon> is your first language, or your only exposure prior to this was something
Jon> like shell scripting then the Camel book can be difficult to downright
Jon> unintelligible, we are not all C programmers, and there is a huge leap
Jon> between Learning Perl and Programming in Perl.
And has been said repeatedly here --
NO ONE gets flamed for asking a question that is not in the FAQ and
not trivially discoverable via a literal search of the online
documentation. NOR do they get flamed if after having read the
documentation they found, they don't udnerstand, as long as they ask a
cogent question and say such.
The flames are directed at questions that are:
1) word for word from the FAQ, and it's obvious they haven't read the FAQ
2) trivally grep'able from the online docs
3) vaguely worded, or worded in such a way that we know they didn't even try
4) off topic (like CGI that's perl-irrelvant)
5) bad netiquette (MIME, long, too much quoted, quoted-unprintable, etc)
And I still say those are all legitmate flames. If I went into
comp.unix.questions, and said "what are the options to 'ls'?", I would
expect to be flamed, whereas if I ask "how does the default sorting
order differ from the -c option? I've read the docs and don't get
it", that's a *good* question, and should be answered.
Now map that onto what you've seen here.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 164 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
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 2145
**************************************