[15457] in Perl-Users-Digest
Perl-Users Digest, Issue: 2867 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 26 09:05:25 2000
Date: Wed, 26 Apr 2000 06:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <956754308-v9-i2867@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Apr 2000 Volume: 9 Number: 2867
Today's topics:
[Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
Re: Can anyone recommend a good book <schoell@lsil.com>
Re: clearning contents of a hash <anon@nic.harvard.edu>
Re: Critique My Code <anon@nic.harvard.edu>
Re: Critique My Code nobull@mail.com
Re: Form to Html template sample code neede earthly@my-deja.com
How to attach a file sending a mail via sendamil server <koreags@thrunet.com>
Re: How to attach a file sending a mail via sendamil se (Villy Kruse)
How to Print Name of Input File with Successful Matches <e.roselli@volusoft.com>
Re: How to Print Name of Input File with Successful Mat <e.roselli@volusoft.com>
Re: Newbie question <maciek@treko.net.au>
Re: Opening /var/spool/mail/username (Villy Kruse)
Re: overloading & 'constant' subroutines <b.keck@trl.telstra.com.au>
Perl and SQL Gordon.Haverland@agric.gov.ab.ca
Re: Perl database Access <vautour@unb.ca>
Re: Problem with getting return value from a function c nobull@mail.com
Re: script help! (Someone Special)
Similar problem andrewspruce@my-deja.com
Similar problem andrewspruce@my-deja.com
Sort on xx-st piece of array <ppi@searchy.net>
Re: Sort on xx-st piece of array nobull@mail.com
Re: to print a flat data file with a certain lengths ? <koreags@thrunet.com>
use strict; isn't good enough <dwb1@home.com>
Re: use strict; isn't good enough <rhomberg@ife.ee.ethz.ch>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Apr 2000 10:23:00 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage956744640.8790@news.teleport.com>
Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 8 Feb 2000
[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]
For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).
http://www.cpan.org/doc/FAQs/
Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.
perldoc perlfaq
man perlfaq
If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.
If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.
http://www.cpan.org/
http://www.perl.com/CPAN/
http://www.cpan.org/doc/FAQs/FAQ/html/
http://www.perl.com/CPAN/doc/FAQs/FAQ/html/
You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)
California ftp://ftp.cdrom.com/pub/perl/CPAN/
Texas ftp://ftp.metronet.com/pub/perl/
South Africa ftp://ftp.is.co.za/programming/perl/CPAN/
Japan ftp://ftp.dti.ad.jp/pub/lang/CPAN/
Australia ftp://cpan.topend.com.au/pub/CPAN/
Netherlands ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
Switzerland ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
Chile ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/
If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.
Have fun with Perl!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 26 Apr 2000 12:59:03 +0200
From: Apollinaris Schoell <schoell@lsil.com>
Subject: Re: Can anyone recommend a good book
Message-Id: <tkhfcpyvpk.fsf@lsil.com>
Hi
The Perl CD Bookshelf
It contains 6!! O'Reilly books on CD(including a search engine which runs on
*nix and windows) and 'Perl in a Nutshell'.
Polli
"Mark Rendle" <rendle@clara.co.uk> writes:
> I'm completely new to perl, never seen it before, but I've been programming
> for over 10 years, used Unix ksh, still remember some awk, more recently
> been using VC++ and VB, HTML and Javascript, need to learn CGI/Perl in a
> hurry. Can somebody recommend the best book to go from knowing nothing of
> perl to competent CGI scripting in about a week? Looked on amazon.co.uk but
> the reviews contradict each other horribly...
>
> Thanks in advance,
>
> --
>
> Mark R
> http://www.markrendle.co.uk (new and improved!)
------------------------------
Date: Tue, 25 Apr 2000 16:43:40 -0400
From: <anon@nic.harvard.edu>
Subject: Re: clearning contents of a hash
Message-Id: <250420001643403299%anon@nic.harvard.edu>
> On Fri, 21 Apr 2000 15:42:37 +0000 James Philip Ryan wrote:
> > i need to remove all elements of a hashtable or hashtables, is there a
> > way i can remove the root hashtable from memory entirely?
There's always--
undef %hash;
check 'perldoc -f undef'
------------------------------
Date: Tue, 25 Apr 2000 17:08:08 -0400
From: <anon@nic.harvard.edu>
Subject: Re: Critique My Code
Message-Id: <250420001708083119%anon@nic.harvard.edu>
> I've read the docs on the taint switch, but I don't understand it. What does
> it do? Why is it useful?
It checks to make sure you don't do anything horrifically insecure with
the stuff that lives outside of your perl script: calls to the command
line, reading from and writing to files, etc.
Typical things taint won't let go without a fight:
--passing unexamined user-supplied variable values to the command line,
or variables that get their values from other user-supplied variable
values
--calling command line programs without ensuring the proper path (keep
hackers from replacing, say, '/usr/bin/ls' with '/my/nasty/ls'
--writing unexamined user data to files
Of course, it's fairly easy to get around these in an insecure manner;
taint mostly exists to let you know you're doing something you should
think very carefully about.
------------------------------
Date: 26 Apr 2000 13:25:34 +0100
From: nobull@mail.com
Subject: Re: Critique My Code
Message-Id: <u98zy1rqv5.fsf@wcl-l.bham.ac.uk>
Larry Rosler <lr@hpl.hp.com> writes:
> In article <u9g0sbml3f.fsf@wcl-l.bham.ac.uk> on 24 Apr 2000 19:04:36
> +0100, nobull@mail.com <nobull@mail.com> says...
> > "Gabe" <grichards@flashcom.net> writes:
> >
> > > I'm a relative novice. I've never had any formal programming training, so I
> > > wonder if my programs are just horribly inefficient. I'm looking for
> > > efficiency and style advice.
> >
> > Looks fairly damn good to me. I've offered a bit of style advice. Of
> > course there are no absolutes in style and many people may disagree
> > with me.
>
> Why 'may'? I'd call it a sure thing. :-)
>
> > > Are there better methods to do what I'm trying
> > > to do?
> >
> > GCI.pm provides methods to compose HTML and I notice that you've not
> > used them and generate HTML on-the-fly bit by bit in loops. Generally
> > I prefer to build lists then use the fuctions in GCI.pm to build the
> > HTML. Looks neater (runs slower).
>
> See, first disagreement. I've written programs either way, and don't
> see much advantage to the HTML-generating routines in CGI.pm.
Not really a disagreement. I use both approaches too. But for scripts
generating HTML tables I find that marshalling the results into a Perl
structure and then using an expression made up from map() and the
CGI.pm HTML functions can make for more maintanable code. In Gabe's
case I think it would make the code more maintanable but I'm really
just offering Gabe an alternative to consider.
> > > #!/usr/local/bin/perl
>
> I would add the '-w' flag and (unless you prefer to have diagnostics go
> to the server log):
>
> use CGI::Carp 'fatalsToBrowser';
Good point, how did I miss that?
> > > main: {
> > > &event;
> >
> > It's generally considered better style to declare your subroutines
> > before you use them rather than need to put in an explict & in the
> > call.
>
> That way lies Pascal (upside-down programs). If you object to
> '&event;', just use
>
> event();
I agree that this is more elegant but it's not, primarity, the syntax
that I object to, it's the semantics.
Admitedly this is a religous disagreement. I respect the right of the
followers of K&R C gods to worship in whatever temple they choose even
when in the land of Perl. I still think that the mainstream
programming religions consider unecessary calls to unprottyped
functions to be unpious (if not actually sinful).
If you don't like upside-down programs then you need only declare (not
define) your subroutines in advance.
Personally I like upside-down programs. In practice the main body is
never actaully the first thing in a program (all those file-scope my
variables and so on). IMHO, to make it easy to find the best place to put
the main body is last.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Apr 2000 11:54:37 GMT
From: earthly@my-deja.com
Subject: Re: Form to Html template sample code neede
Message-Id: <8e6ldp$oq7$1@nnrp1.deja.com>
In article <m14s8uusxj.fsf@halfdome.holdit.com>,
merlyn@stonehenge.com (Randal L. Schwartz)
wrote:
> >>>>> "Randal" == Randal L Schwartz
<merlyn@stonehenge.com> writes:
>
> >>>>> "ELPHIDE" == ELPHIDE <NA@NA.ORG> writes:
>
> Randal> [aside - Are you *really* with Narcotics
Anonymous? I can't tell if
> Randal> your address is a spamblock (in which
case you are being evil because
> Randal> it's also possibly a valid address) or
the real thing. Some .sig
> Randal> lines would help here, sir.]
But (says who?) another says, look at all the
trouble to send without risk of spam : get out of
newsgroup, get in browser, get engine to locate,
write 'anon' message; just because of the xxx
stuff that shows up
>
> No, mail to it bounced. So you are an evil
person because you are
> essentially stealing the resources of another
valid domain holder just
> so spammers won't find you. <sigh>
>
> --
> Randal L. Schwartz - Stonehenge Consulting
Services, Inc. - +1 503 777 0095
> <merlyn@stonehenge.com>
<URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical
writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and
open-enrollment Perl training!
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 25 Apr 2000 15:01:52 +0900
From: "Joe" <koreags@thrunet.com>
Subject: How to attach a file sending a mail via sendamil server ?
Message-Id: <h9n38rnr$GA.107@news.thrunet.com>
Hi,
How to attach a file sending a mail via sendamil server ?
I'm trying to add a text file which is on same directory on certain time.
How can I handle this ?
open (MAIL, "| $sendmail -t") || die "I can't open sendmail\n";
print MAIL "To: $email_address\n";
print MAIL "From: abc<$my_mail>\n";
print MAIL "Subject: $Title\n";
print MAIL "Here I'm trying to attach a file\n";
print MAIL
"-------------------------------------------------------------\n";
print MAIL "Thank you\n";
close(MAIL);
------------------------------
Date: 26 Apr 2000 12:39:48 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: How to attach a file sending a mail via sendamil server ?
Message-Id: <slrn8gdosk.6ph.vek@pharmnl.ohout.pharmapartners.nl>
On Tue, 25 Apr 2000 15:01:52 +0900, Joe <koreags@thrunet.com> wrote:
>Hi,
>How to attach a file sending a mail via sendamil server ?
>
>I'm trying to add a text file which is on same directory on certain time.
>How can I handle this ?
>
Go to CPAN and get MIME::Lite or MIME::Tools. The documentations
include examples of how to add an attachment to a mail message.
Villy
------------------------------
Date: Wed, 26 Apr 2000 13:39:12 +0300
From: "Elisa Roselli" <e.roselli@volusoft.com>
Subject: How to Print Name of Input File with Successful Matches?
Message-Id: <8e6ksu$g03$1@wanadoo.fr>
I have a very simple task that I need to do quickly, but I'm having trouble
remembering or finding the exact syntax.
I have a little program that reads in from the diamond operator a list of
files specified in the command line at runtime. It checks them all for the
presence of a particular regex and extracts it every time it finds it. But I
also want it to tell which file the extraction is coming from, and can't
remember, from the plethora of dollars this and dollars that, which variable
it is in Perl that will do what "print FILENAME" will do in awk.
This is the program as it currently stands:
***
#!/usr/local/bin/perl -w
use strict;
# the line that I hope will keep track of the input file names
foreach (@ARGV) {
while (<>) {
$/ = "\n\n";
# the part that finds and prints the regex is working
if (/update\s+.*set\s+.*\[\s*.*where/) {
print $_;
# the part that doesn't work as I was hoping. Why won't it just print
the name
# of the current file in the @ARGV array?
print $ARGV;
}
}
}
It's not laziness so much as a supervisor who, when he asks a question,
wants the answer yesterday and really will not put up with losing me on the
beguiling paths of reasearch for an afternoon.
Help and patience would be mush appreciated.
Elisa Francesca Roselli
------------------------------
Date: Wed, 26 Apr 2000 13:50:30 +0300
From: "Elisa Roselli" <e.roselli@volusoft.com>
Subject: Re: How to Print Name of Input File with Successful Matches?
Message-Id: <8e6li6$gs3$1@wanadoo.fr>
Please don't bother answering - I got the solution a few minutes after I
came whining into the forum. In fact the program worked, but I didn't see
that it worked because I forgot to put in a few newlines to make the output
readable.
Sorry for wasting bandwidth.
EFR
Elisa Roselli a écrit dans le message <8e6ksu$g03$1@wanadoo.fr>...
>***
>#!/usr/local/bin/perl -w
>
>use strict;
>
># the line that I hope will keep track of the input file names
>foreach (@ARGV) {
> while (<>) {
> $/ = "\n\n";
>
> # the part that finds and prints the regex is working
> if (/update\s+.*set\s+.*\[\s*.*where/) {
> print $_;
> # the part that doesn't work as I was hoping. Why won't it just print
>the name
> # of the current file in the @ARGV array?
> print $ARGV;
>
> }
> }
>}
------------------------------
Date: Wed, 26 Apr 2000 19:51:48 +0800
From: Maciej Mastalarczuk <maciek@treko.net.au>
Subject: Re: Newbie question
Message-Id: <3906D854.6087A8E8@treko.net.au>
> No, but seriously,
> I'll assume that you know what root is. I'm no unix guru but I do know how
> serious root access is. If you don't know get a book on unix or find an
> appropriate newsgroup for unix.
> Now onto the script issue. You never want to put any password or other
> critical information inside your script. Why? A hacker can simply download
> the scipt and take the password out of the script. Simple. Encryption is
> just an irritation to a decent hacker. Naming the file .cgi won't stop them.
> Neither will placing it in a executable dir. Then they've got root to your
> ENTIRE system. This includes the other web developers/sites that may be
> sharing that server with you. This could potentially cost more than a little
> dough. At the very least an enormous headache.
>
> What exactly do you need to do that requires root?
> If you absolutely need root use setuid
Allright, allright, allright... :-)
I know what root is and how painfull it can be. Despite I am a newbe to Perl I
am not that newbie to the rest and I realize security problem. The problem (not
mine) is that somebody needs to perform a basic system maitenance using web
page. The user is not experienced and just cannot use shell to do it. Hence,
secure or not my script has to execute a command as a root. Otherwise I'm in
trouble :-)
I was looking for the best method of doing so. Setuid probably seems to be the
best idea.
I was also thinking about the following:
The script (running as nobody) records the actions to be performed in say a file
or database.
Crond is polling the database and if it finds a request invokes another script
as root to do the job.
Does it sound any better?
Certainly if anyone hacks the database there is a problem as a hacker's request
can be put there, but root password is secure.
Thank you all for the reply.
Cheers
Maciej Mastalarczuk
------------------------------
Date: 26 Apr 2000 12:45:43 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Opening /var/spool/mail/username
Message-Id: <slrn8gdp7m.6ph.vek@pharmnl.ohout.pharmapartners.nl>
On Wed, 26 Apr 2000 11:10:52 +0100, Oli Kessler <ok@tor.ch> wrote:
>
>It will only be possible if you set your perl script suid root, a practice
>commonly used when implementing webmailers that access the mailboxes directly.
>Notice however, this is a major security risk (assuming you will be accepting
>input over the web .......).
>
Also, pay very close attention on how to correctly lock the mail box file
against conflicting access. Otherwise you may loose messages.
>Consider also using a Imap or POP server in-between like the following:
>
>mailer.cgi <-----> IMAP server <-----> /var/spool/mail/X
>
>and restrict the access to the IMAP server to localhost
>(via /etc/hosts.[allow|deny] )
>
I would think that a POP server solution would be safer. It also solves
the problem on how to handle the login name and password, without needing
to open and read the passwd or shadow file.
--
Villy
------------------------------
Date: 26 Apr 2000 11:07:42 GMT
From: Brian Keck <b.keck@trl.telstra.com.au>
To: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: overloading & 'constant' subroutines
Message-Id: <8e6ilu$d6h$1@news.cdn.telstra.com.au>
On Tue, 25 Apr 2000 23:25:08 MST, Tom Phoenix wrote:
>On 26 Apr 2000, Brian Keck wrote:
>> sub x { new Math::BigInt "1000000"; }
>
>That's not a constant subroutine; it's a subroutine whose code returns a
>new Math::BigInt every time it's called.
Well, the reason I put 'constant' in quotes was my quiet confidence that
I was using the term incorrectly.
> use constant x => new Math::BigInt "1000000";
>
>Now _that_'s a constant subroutine! (Perl can in-line that value nearly
>every time it's used, doing constant folding as necessary.)
>
>Still, I'm not sure why your original code didn't work; it looks to me as
>if it's a bug in the overloading, or in Math::BigInt. Good luck with it!
Fixed it myself in the end as you probably saw.
Thanks,
Brian Keck
------------------------------
Date: Wed, 26 Apr 2000 12:28:05 GMT
From: Gordon.Haverland@agric.gov.ab.ca
Subject: Perl and SQL
Message-Id: <3906dfb8.76686503@news.gov.ab.ca>
Hi!
I've been using perl for quite a while, and like using perldb in
emacs when debugging stuff. Just recently I started working on a
program which makes use of a SQL dbase (PostgreSQL in particular), and
trying to find out what's wrong is becoming quite a chore. Are there
any modules which should be use'd or require'd to help in tracking
down why the SQL calls fail? Like perl, sometimes an error message is
caused by something missing or extra previously, and so things aren't
always as simple as the seem. Advice on using large objects also
welcomed. :-) Thanks,
Gordon Haverland
------------------------------
Date: Wed, 26 Apr 2000 09:09:06 -0300
From: Gil Vautour <vautour@unb.ca>
Subject: Re: Perl database Access
Message-Id: <3906DC62.D1AEFC62@unb.ca>
With regard to your second alternative, how exactly does the Windows machine
figure into the mix? For an Access database to be accessible on the Web,
does this mean the Windows machine would need to always be available for a
connection on the Solaris box to occur?
Jonathan Stowe wrote:
> On Tue, 25 Apr 2000 14:54:22 -0300 Gil Vautour wrote:
> >
> > I was wondering if it is possible to access a MS Access database on a
> > Solaris box using Perl and DBI? If so, are there any good resources
> > on the Web for this sort of thing?
> >
>
> There are at least two optons. Neither of which involves reading Access
> file directly on the Solaris box. Firstly you can export the data to
> some format that can easily be read on the Unix machine (such as CSV) or
> you can export it and import it into some database running on the
> Solaris machine. Alternatively you can run dbiproxy on some windows
> machine with an ODBC DSN set up for your Access database and use the
> DBI driver DBD::Proxy to access it from your Solaris. Bear in mind that
> Access is by no means a proper multiuser database and you are highly
> likely to break it if you put it under any significant load.
>
> /J\
> --
> Marge, it takes two to lie. One to lie and one to listen.
> --
> fortune oscar homer
------------------------------
Date: 26 Apr 2000 13:24:40 +0100
From: nobull@mail.com
Subject: Re: Problem with getting return value from a function call
Message-Id: <u9aeihrqwn.fsf@wcl-l.bham.ac.uk>
Chris Lacey <stingray@davesworld.net> writes:
> Subject: Re: Problem with getting return value from a function call
Your problem has nothing to do with getting return value from a
function call.
> if (\$choice eq "Y" or "y") {
Check out "perldoc perlop" for the definitions of the "\" operator and
the "or" operator. You clearly have some serious misconceptions about
what they do.
if ($choice eq "Y" or $choice eq "y") {
or
if (lc($choice) eq "y" ) {
or (less efficiently but some prefer it):
if ($choice =~ /^Y$/i ) {
--
\\ ( ) No male bovine | Email: B.A.McCauley@bham.ac.uk
. _\\__[oo faeces from | Phones: +44 121 471 3789 (home)
.__/ \\ /\@ /~) /~[ /\/[ | +44 121 627 2173 (voice) 2175 (fax)
. l___\\ /~~) /~~[ / [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
# ll l\\ ~~~~ ~ ~ ~ ~ | http://www.wcl.bham.ac.uk/~bam/
###LL LL\\ (Brian McCauley) |
------------------------------
Date: Wed, 26 Apr 2000 12:41:35 GMT
From: info@nowhere.com (Someone Special)
Subject: Re: script help!
Message-Id: <3906e3a6.406105629@news.fast.net>
On Tue, 25 Apr 2000 14:52:04 -0700, Tom Phoenix <rootbeer@redcat.com>
wrote:
>On Tue, 25 Apr 2000 dreiger@rnci.com wrote:
>
>> Subject: script help!
>
>> I am NOT any kind of programmer
>
>So, do you want to become a programmer, or to hire one? If you're looking
>to become one, perhaps you should search for an introductory course on
>programming. If you'd like to hire one, there are many newsgroups with
>'jobs' in their names, or you could just visit your local Perl Mongers.
>
I think you missed the point - I don't plan to ever be a programmer,
and have had this project dumped on me, with no options but to write
this, or job hunt.
>
>Good luck with it!
>
>--
>Tom Phoenix Perl Training and Hacking Esperanto
>Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
>
------------------------------
Date: Wed, 26 Apr 2000 12:43:38 GMT
From: andrewspruce@my-deja.com
Subject: Similar problem
Message-Id: <8e6o9n$rqr$1@nnrp1.deja.com>
We have a similar problem :
As per man page we fork and if the allocation
returns non-zero defined value we do parent stuff:
if (my $pid = fork) {
# Parent stuff
$children++;
$usedDbh{$pid} = $dbh;
next TABLE;
} elsif (defined $pid) {
# Child stuff
my $rows = 0;
my $context = new SHA;
$context->reset;
}
else {
# undef handling
}
We get zombies (entries in the process table
marked as <defunct>) and the parent has some max
number of children logic so when all slots
allocated are defunct the parent simply sits and
waits.
We do not use signal handlers for the child.
Any ideas ?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 26 Apr 2000 12:43:40 GMT
From: andrewspruce@my-deja.com
Subject: Similar problem
Message-Id: <8e6o9p$rqt$1@nnrp1.deja.com>
We have a similar problem :
As per man page we fork and if the allocation
returns non-zero defined value we do parent stuff:
if (my $pid = fork) {
# Parent stuff
$children++;
$usedDbh{$pid} = $dbh;
next TABLE;
} elsif (defined $pid) {
# Child stuff
my $rows = 0;
my $context = new SHA;
$context->reset;
}
else {
# undef handling
}
We get zombies (entries in the process table
marked as <defunct>) and the parent has some max
number of children logic so when all slots
allocated are defunct the parent simply sits and
waits.
We do not use signal handlers for the child.
Any ideas ?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 26 Apr 2000 12:09:43 +0200
From: Penpal International <ppi@searchy.net>
Subject: Sort on xx-st piece of array
Message-Id: <3906C067.55F4DD70@searchy.net>
This is a multi-part message in MIME format.
--------------F904E6D655B419688658979E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I have an array loaded from a file (I've attached it). All fields are
splitted by a \| . The last one of them must also be splitted with <|>
(< or >). Does anyone know how to sort the lines of the file?
Thanks,
Frank de Bot
--
Penpal International
http://ppi.searchy.net/
ppi@searchy.net
--------------F904E6D655B419688658979E
Content-Type: text/plain; charset=us-ascii;
name="trackers.dat"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="trackers.dat"
test.gen|<a href=Penpal International Test Counter>http://ppi.searchy.net/</a>|955918959|<font color=#00CC00>Good</font>
test1.gen|<a href=Penpal International>http://ppi.searchy.net/</a>|956491253|<font color=#00CC00>Good</font><font color=#CCCC00>New!</font>
ppi.gen|<a href=0>5 February 2000</a>|Frank de Bot|<font color=#CC0000><blink>Bad: 1</blink></font>
bonnie.gen|<a href=Bonnie's Penpal Directory>http://members.tripod.com/~Bonnie_C/</a>|955979633|<font color=#00CC00>Good</font>
henkjan.gen|<a href=Henk-Jan's Homepage>http://home.concepts.nl/~pa3gmi/index.htm</a>|955650019|<font color=#00CC00>Good</font>
viool.gen|<a href=Thomas Geever, Vioolbouwer>http://viool.searchy.net/</a>|955918044|<font color=#00CC00>Good</font>
--------------F904E6D655B419688658979E--
------------------------------
Date: 26 Apr 2000 13:25:48 +0100
From: nobull@mail.com
Subject: Re: Sort on xx-st piece of array
Message-Id: <u97ldlrqur.fsf@wcl-l.bham.ac.uk>
Penpal International <ppi@searchy.net> writes:
> I have an array loaded from a file (I've attached it). All fields are
> splitted by a \| . The last one of them must also be splitted with <|>
> (< or >). Does anyone know how to sort the lines of the file?
See FAQ: "How do I sort an array by (anything)?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 25 Apr 2000 14:54:55 +0900
From: "Joe" <koreags@thrunet.com>
Subject: Re: to print a flat data file with a certain lengths ?
Message-Id: <QXvWEonr$GA.343@news.thrunet.com>
Thanks Jeff
I got it.
>Do you *really* mean to tell us that you can not figure that out
>yourself with some simple experimentation with what you have already
>been shown? If "$x . $space" puts the space on the right, don't you
>think "$space . $x" might put the space on the left? You could also try
>reading about the sprintf() function which also does padding.
>
>--
>Jeff
------------------------------
Date: Wed, 26 Apr 2000 11:32:45 GMT
From: <dwb1@home.com>
Subject: use strict; isn't good enough
Message-Id: <Pine.LNX.4.20.0004260638580.8578-100000@ethyl.addictmud.org>
Is there a way to get perl to validate function calls on execution?
"use strict" is wonderful for variables, but doesn't seem to work
for function calls... I need to be able to know at compile-time if
a function used by a perticular script is actually available to the
script or module calling it... right now, the scripts just wait until
they get to that function and bomb if it can't find it...
While I do test my scripts thuroughly, it would help my development
time if this kind of checking were doable...
Thanks
Dan.
------------------------------
Date: Wed, 26 Apr 2000 14:07:23 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: use strict; isn't good enough
Message-Id: <3906DBFB.2B73C677@ife.ee.ethz.ch>
dwb1@home.com wrote:
>
> Is there a way to get perl to validate function calls on execution?
You mean at compile time..
use the critical function calls without ampersands or parens:
% perl -Mstrict -wle'print 1;b 1'
Execution of -e aborted due to compilation errors.
% perl -Mstrict -wle'print 1;b(1)'
1
Undefined subroutine &main::b called at -e line 1.
% perl -Mstrict -wle'print 1;&b'
1
Undefined subroutine &main::b called at -e line 1.
- Alex
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 2867
**************************************