[10411] in Perl-Users-Digest
Perl-Users Digest, Issue: 4004 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 18 20:02:26 1998
Date: Sun, 18 Oct 98 17:00:24 -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, 18 Oct 1998 Volume: 8 Number: 4004
Today's topics:
Re: Are there no PERL experts out there?? Is there no o (Marc Haber)
Re: Are there no PERL experts out there?? Is there no o (Alexander Trump)
changing route for users via html page <freerk@dds.nl>
File I/O <newsonly@usa.net>
Re: File I/O (Honza Pazdziora)
Re: File I/O <newsonly@usa.net>
Re: I have a few elementary Perl problems <garry@america.net>
Re: Insecure $ENV{PATH} while running setuid at /home/x <tpot@acsys.anu.edu.au>
Re: Internet Explorer problem with file extension when (Martien Verbruggen)
Re: interogate values from a select multiple? (Michael Budash)
IO::Socket error <marius@odin.funcom.com>
Re: newbie: multidim array format (Alexander Trump)
open3() problems, buffering and alternate strategies? (Malcolm Hoar)
Passing by Reference for Performance Reasons? (Joachim Zobel)
Re: Passing by Reference for Performance Reasons? <jdf@pobox.com>
Re: Perl and resizing JPEGs <michael@mks-tech.com>
Perl DBI AND Oracle (ORACLE_HOME) <gk@clara.net>
Re: Perl DBI AND Oracle (ORACLE_HOME) <wilrod@nospam.rocketmail.com>
Re: Perl DBI AND Oracle (ORACLE_HOME) (Honza Pazdziora)
Re: perl-program binary (Martien Verbruggen)
Re: problems calling procmail <jdf@pobox.com>
Re: problems calling procmail <garry@america.net>
Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has regi <matt@whiterabbit.co.uk>
Re: Slow Sort? <alexis@danae.demon.co.uk>
Re: Slow Sort? (Steve Monson)
Re: Storing object attributes in a DB_HASH? <dgris@perrin.dimensional.com>
Re: Storing object attributes in a DB_HASH? <Savage.Ron.RS@bhp.com.au>
Re: sub and return <matt@whiterabbit.co.uk>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 18 Oct 1998 19:12:10 GMT
From: Marc.Haber-usenet@gmx.de (Marc Haber)
Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
Message-Id: <70del7$pqf$1@test-news.rz.uni-karlsruhe.de>
bart.mediamind@ping.be (Bart Lateur) wrote:
>Lloyd Zusman wrote:
>>If you have a pre-conceived notion that no one ever expresses
>>gratitude in c.l.p.misc, then you are likely to overlook the many
>>instances of thanks that routinely are given here.
>
>Thank you notes are off-topic.
But IIRC widely tolerated :-)
Greetings
Marc
--
-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber | " Questions are the | Mailadresse im Header
Karlsruhe, Germany | Beginning of Wisdom " | Fon: *49 721 966 32 15
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fax: *49 721 966 31 29
------------------------------
Date: Mon, 19 Oct 1998 00:13:53 +0500
From: assa@assa.tlt.ru (Alexander Trump)
Subject: Re: Are there no PERL experts out there?? Is there no one who can solve this??
Message-Id: <hled07.432.ln@assa61.assa.tlt.ru>
David Alan Black (dblack@pilot.njin.net) wrote:
: Rafely@xxiname.com writes:
: >I'm making a form so users can send me information.
: >The also have to send me their name. How do I check
: >and see if the name only consists of letters and white
: >spaces?? So "My Name" is allowed but "Jj&*d d#fdhd"
: >is not allowed!!! I want to send a message saying that
: >the name was invalid! But how do I check and see if
: >the name is valid? I've posted this questions several
[...]
: It isn't a very easy question. Well, it's easy to do what you
: literally asked for:
: /^([^\W\d_]|\s)+$/
I suppose
print "Error!" if (/[^A-Za-z\s]/);
will be better. You may easily extend the list of allowed character. The
only point you'll need special consider - user may use minus sign '-' in the
name, but it isn't [\w] - character. Be warned.
Complex euristics for real checking is a good thing, but I guess they're
useless in this case.
--
Sincerely, Alexander
------------------------------
Date: Mon, 19 Oct 1998 13:15:49 +0200
From: Freerk Jongsma <freerk@dds.nl>
Subject: changing route for users via html page
Message-Id: <362B1F65.240FE6C1@dds.nl>
Users in our library (mostly students) are able to use the internet.
This is now unlimited. We would like to create a situation that our
librarian can klik on a html-page (a map of the library with the
computers on it) and activate the connection of a particular computer
(put the route to this machine in the list). Maybe even for only one our
or so (with a timer so you don't have to think about it). But the last
point is for later concern.
To have a normal user use - via a html page - the 'route' command, he or
she has to have 'root' rights. A browser contact gives you mostly the
rights of 'nobody' on the server.
I was thinking of a perl script that gives the user 'root' rights by the
'su' command.
Put also the root password in the script, the 'route' command and with a
ctrl-D the user becomes within the script a normal user again.
The problem I have now is that I could not find how I have to fix the
problem of executing the 'su' command for becoming root user. And that
with the use of the password within the program.
And how to execute the ctrl-D command?
Does anyone know how I have to do this?
Am I on the right way, or is it very stupid to put the password in the
perl script?
Is it possible to read the script? I use Apache under linux and so the
cgi-bin is NOT in the www-root.
Freerk
------------------------------
Date: Sun, 18 Oct 1998 15:18:54 -0400
From: "Bob L." <newsonly@usa.net>
Subject: File I/O
Message-Id: <g7rW1.160$H9.45354@proxye1.nycap.rr.com>
Hi:
I have banner code that runs on many pages on my site. I use an EXEC to run
a perl script. Here's the flow:
1. Open the file.
2. Read the data
3. Close the file
4. Determine which banner to display
5. Open the file for write
6. Write the counters which have been updated
7. Close the file.
I changed the code to open the file and leave it open while it is processing
so another web page that calls the EXEC will not use the data before it has
been updated. I also used flock to lock the file.
I now have:
1. Open the file.
1.1 lock the file (flock(FILE,2);
2. Read the data
4. Determine which banner to display
6. Write the counters which have been updated
6.1 unlock the file (flock(FILE,8)
7. Close the file.
Here is my question.
1. If a request comes in and the server executes the EXEC which locks the
file AND another web page request comes to the server and causes the server
to process the same EXEC, will the second cgi script wait until the file is
unlocked or will it die somehow?
2. I trid using +> when I open the file for read and write but for some
reason it will not write the counters to the file. Any idea why?
Thank you very much.
Bob
------------------------------
Date: Sun, 18 Oct 1998 20:02:16 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: File I/O
Message-Id: <slrn72kia9.gf2.adelton@aisa.fi.muni.cz>
On Sun, 18 Oct 1998 15:18:54 -0400, Bob L. <newsonly@usa.net> wrote:
> 1. If a request comes in and the server executes the EXEC which locks the
> file AND another web page request comes to the server and causes the server
> to process the same EXEC, will the second cgi script wait until the file is
> unlocked or will it die somehow?
It won't die (unless you make it to). It will wait, unless you use
a non-blocking lock.
> 2. I trid using +> when I open the file for read and write but for some
> reason it will not write the counters to the file. Any idea why?
Maybe the process died for some reason before it had a chance to
write. But it's hard to say when we do not see the actual code. So
post a short (but complete) example and we might be able to make some
sense of that.
Hope this helps,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
I can take or leave it if I please
------------------------------------------------------------------------
------------------------------
Date: Sun, 18 Oct 1998 19:02:19 -0400
From: "Bob L." <newsonly@usa.net>
Subject: Re: File I/O
Message-Id: <1puW1.172$H9.53270@proxye1.nycap.rr.com>
Hi and thank you:
I have included the I/O code below. I tried +> when I open the file and it
will not write to the file. Actually, the file gets wiped out. My first
question was answered but now another short one. if 2 cgi's need to access
the same text file and one of the cgi's is running, when the second
executes, what happens when the file is locked as shown below?
I really appreciate your help on this.
Bob
# Open the file containing phrases and read it in.
open(FILE,"$random_file") || &error('open->random_file',$random_file);
flock(FILE,2);
@FILE = <FILE>;
#close(FILE);&print_line;
sub print_line {
THE VARIABLE $NEWFILE IS SET IN THE CODE I DELETED
# open(CHANGE, ">$random_file");
print FILE $newfile;
flock(FILE,8);
close(FILE);
exit;
}
------------
------------------------------
Date: Sun, 18 Oct 1998 22:53:38 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: I have a few elementary Perl problems
Message-Id: <362A71D1.2CF7D143@america.net>
Garry T. Williams wrote:
<snip>
> If you want the output of the local machine's command to be redirected
> to a file on the local machine, then the call to Perl's system function
> needs to look something like this:
>
> system("rsh machine \"ls\" > path")
Well, I was wrong, here. The escaped quotes around rsh's command are
not relevant. The only question is whether or not the shell's
*metacharacters* are escaped. Escaping them allows them to be "seen" by
the remote machine's shell. Leaving them alone gets them processed by
the local machine's shell.
> If instead, you want the output of the remote command to be redirected
> to a file on the remote machine, you need something like this:
>
> system("rsh machine \"ls > path\"")
This could be rewritten as:
system("rsh machine ls \">\" path")
or simply:
system("rsh machine ls '>' path")
and have the same effect.
-Garry Williams
------------------------------
Date: 19 Oct 1998 09:17:39 +1000
From: Tim Potter <tpot@acsys.anu.edu.au>
To: dlenox@ssix.net
Subject: Re: Insecure $ENV{PATH} while running setuid at /home/xxx/cgi-bin/sendmail.pl
Message-Id: <6yaf2tmpd8.fsf@acronym.anu.edu.au>
Daniel Lenox <dlenox@ssix.net> writes:
> Recently brought Linux 2.0.25 server and tried running sendmail.pl
> (known working script) called by .html form processing.
>
> Offending line is : open (MAIL, "|/usr/sbin/sendmail -t");
>
> Script works fine executed from command prompt, permissions on sendmail
> are 4755 any ideas what is happening here? apache.org strongly
> suggested this was strictly perl related....
Is your script running setuid? The fact that sendmail is also setuid
shouldn't matter in this case.
When you are running setuid, perl turns on "taint checking" to ensure
you don't do anything obviously silly that would result in a security
hole. Check out the relevant sections in the camel book. To get
around the insecure $ENV{PATH}, add something like this to your script
before you open the sendmail process:
$ENV{PATH} = "/bin:/usr/bin";
The security hole perl is checking for involves not explicity setting
the path. If you do not set the path yourself, it is inherited from
the process that started the script. Thus, it is possible for a
malicious user to set the path and if you had not used the full
pathname to sendmail, your script would have run the first program
called sendmail in the user's path. Thus, by copying /bin/sh to
sendmail and putting it in the path, you can gain access to to the uid
that your script is running under.
Tim.
>
> Dan Lenox
>
------------------------------
Date: Sun, 18 Oct 1998 23:26:11 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Internet Explorer problem with file extension when download
Message-Id: <nOuW1.3$O34.948@nsw.nnrp.telstra.net>
In article <7070on$l5b$1@nnrp1.dejanews.com>,
iulian4992@my-dejanews.com writes:
> This works fine with Netscape, but not with IE 4.X When IE sees a file with
> ".jpg" or ".gif" extension it will disregard "Content-type" and will display
> the image in the frame the request initially came from. I found a way around
You have already discovered that this is a problem with IE4, not with
perl. You also are fiddling with HTTP headers, not with a perl
program.
Maybe you should ask in one of the comp.infosystems.www.* groups.
There are groups there that talk about browsers, as well as about the
specifics of CGI and programming for the web.
Here, we like to limit the discussions to perl issues.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Sun, 18 Oct 1998 13:04:49 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: interogate values from a select multiple?
Message-Id: <mbudash-1810981304490001@d48.nas1.napa.sonic.net>
In article <362A251A.A996B487@sd.znet.com>, solomon <solomonf@sd.znet.com>
wrote:
looks like you're not using CGI.pm, or even cgi-lib.pl...
what ARE you using to establish the %e hash? that alone will determine how
the <SELECT MULTIPLE> values are stored, then we can help (maybe)...
--
Michael Budash ~ Michael Budash Consulting
707-255-5371 ~ 707-258-7800 x7736
mbudash@sonic.net
------------------------------
Date: 18 Oct 1998 20:54:20 +0200
From: Marius Kjeldahl <marius@odin.funcom.com>
Subject: IO::Socket error
Message-Id: <52g1clvgyr.fsf@odin.funcom.com>
I've got a perl based server process which accepts connection from
clients. However, in some cases the server process dies (I have not
been able to get this to happen when I control the clients, but when
some of my external users connect/disconnect it triggers the error). From the log, the following error message is generated.
Does anybody have a clue on what is going on, and how I can avoid the
error from being triggered?
Sun Oct 18 05:48:16 1998| xxxxxxxxxxxxxx| new connection
Sun Oct 18 05:48:18 1998| xxxxxxxxxxxxxx| disconnect| forcing logout
Use of uninitialized value at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at /usr/lib/perl5/i386-linux/5.00404/Socket.pm line 249, <GEN11> chunk 1.
Marius
------------------------------
Date: Sun, 18 Oct 1998 23:53:36 +0500
From: assa@assa.tlt.ru (Alexander Trump)
Subject: Re: newbie: multidim array format
Message-Id: <gfdd07.432.ln@assa61.assa.tlt.ru>
Michael D Sohn (msda+@andrew.cmu.edu) wrote:
: For example, say I have a text file that contains a 3 by 3 matrix of
: values:
This is 4 x 3 matrix of values.
:
: 1 2 3 4
: 5 6 7 8
: 9 a b c
:
: I would like to read this file into a variable/array and so that I can
: do stuff to any of the `cells'. Something like:
:
: A[2][3] = 4 + A[4][1]
@A=();
while (<>) {
push @A,[ split ];
}
You'll have excellent list of lists. `man perllol' for details.
--
Sincerely, Alexander
------------------------------
Date: Sun, 18 Oct 1998 20:35:40 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: open3() problems, buffering and alternate strategies?
Message-Id: <362a5121$0$7313@nntp1.ba.best.com>
I am trying to do bi-directional communication with another
application. It accepts data on STDIN and returns its results
on STDOUT. Here's the background:
1. I need to avoid using temporary files (my application
runs as a CGI) and elected to use open3() so that I
could catch STDOUT and STDERR.
2. The external application does NOT create a line of
output for each line of input. Therefore, I wrote all
of the data out and closed the write-side filehandle
before trying to read the results from the read-side
filehandle (per the Camel example on page 456).
This works unless the external application fills its
STDOUT output buffer. Then the whole thing locks up.
3. So, the next step was to use the 4 arg select() and
sysread() to continually service the read-side filehandle
as I sent each record out on the write-side filehandle.
The theory was that this would ensure that the external
applications output buffer would never fill up.
This didn't work at all at first. The output from the
external application was stuck in its output buffer
and not available to my select()/sysread(). I was not
even able to catch the deadlock with $SIG{PIPE}. The
situation did appear to be trappable with $SIG{ALRM}.
4. Finally, I hacked the external application to unbuffer
its STDOUT. This works nicely, at least on my system.
My application needs to run on many systems/platforms.
Hacking the external application on all of those systems
is not really practical. Furthermore, I have noted in
the past, that buffering tends to be very platform-specific.
I don't feel confident that this would represent a
robust and portable solution anyway :-(
I'm kinda stuck and really don't know where to go from
here. Any other pointers/suggestions much appreciated.
FWIW, my development environment:
Perl is Version 5.005_02
Op Sys is FreeBSD 2.2.7-RELEASE
--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar "The more I practice, the luckier I get". |
| malch@malch.com Gary Player. |
| http://www.malch.com/ Shpx gur PQN. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Sun, 18 Oct 1998 20:34:15 GMT
From: jzobel@my-dejanews.com (Joachim Zobel)
Subject: Passing by Reference for Performance Reasons?
Message-Id: <362c50bf.22606088@dilbert.crrrwg.de>
Hi.
i'm passing larger parameters like this:
sub foo {
my($refbar) = @_
# bar won't be changed
...
}
my($bar) = string_of_2kb();
foo(\$bar);
Does it make sense in perl to pass parameters by reference for
performance reasons or does perl internally implement copy on write
and what i'm doing is nonsense?
Thanx,
Joachim
"I read the news today oh boy" - The Beatles - A Day In The Life
Althoug this message has a valid From header, replies
to user@kud.com where user = jzobel are preferred.
------------------------------
Date: 18 Oct 1998 23:27:33 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: jzobel@my-dejanews.com (Joachim Zobel)
Subject: Re: Passing by Reference for Performance Reasons?
Message-Id: <m3g1clblx6.fsf@joshua.panix.com>
jzobel@my-dejanews.com (Joachim Zobel) writes:
> Does it make sense in perl to pass parameters by reference for
> performance reasons or does perl internally implement copy on write
> and what i'm doing is nonsense?
Note that perlsub says "scalars are already passed by reference".
Check out perlsub.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 18 Oct 1998 19:49:02 -0300
From: "Michael K. Steeves" <michael@mks-tech.com>
Subject: Re: Perl and resizing JPEGs
Message-Id: <70dr5b$lj9$1@garnet.nbnet.nb.ca>
Eric Wong wrote in message ...
>Michael K. Steeves <michael@mks-tech.com> wrote:
>: I need either some perl code or a standalone application that will let me
>: resize jpegs (create thumbnails) without haveing to do each one manually.
I....
>
>You might try ImageMagick,
> http://www.wizards.dupont.com/cristy/ImageMagick.html
> http://www.wizards.dupont.com/cristy/www/perl.html
>
>Eric
Yes! It looks good, but I'll have to get it installed and try it.
Thanks.
Michael
------------------------------
Date: Sun, 18 Oct 1998 20:24:30 +0100
From: "Gavin Kuiper" <gk@clara.net>
Subject: Perl DBI AND Oracle (ORACLE_HOME)
Message-Id: <70dfk4$em5$1@eros.clara.net>
Hello,
I have been trying to setup the DBI modules to access a remote Oracle
server. Basically, I have followed all of the steps to make the DBI
modules, however, I am having a problem - when I try to make the Oracle DBM
module - it keeps asking for an ORACLE_HOME environment variable to be set.
This would be easy if the Oracle server was on the same machine - but it is
on a remote machine on the LAN!
My question is: How to I set this variable to reference a remote Oracle
installation (If it is even possible)?
here is some of the error output:
-----------
Configuring DBD::Oracle ...
>>> Remember to actually *READ* the README file!
Especially if you have any problems.
ORACLE_HOME environment variable (c:Orant=) not valid.
-----------
Cheers!
Gavin
------------------------------
Date: Sun, 18 Oct 1998 12:49:16 -0700
From: Wil Rodriguez <wilrod@nospam.rocketmail.com>
Subject: Re: Perl DBI AND Oracle (ORACLE_HOME)
Message-Id: <362A463C.EF3D178E@nospam.rocketmail.com>
Hi,
I believe that you will need the Oracle client utilities installed. The DBD
module is probably looking for header files to include (compile with) on the
client machine under ORACLE_HOME.
Wil
Gavin Kuiper wrote:
> Hello,
>
> I have been trying to setup the DBI modules to access a remote Oracle
> server. Basically, I have followed all of the steps to make the DBI
> modules, however, I am having a problem - when I try to make the Oracle DBM
> module - it keeps asking for an ORACLE_HOME environment variable to be set.
> This would be easy if the Oracle server was on the same machine - but it is
> on a remote machine on the LAN!
>
> My question is: How to I set this variable to reference a remote Oracle
> installation (If it is even possible)?
>
> here is some of the error output:
> -----------
> Configuring DBD::Oracle ...
> >>> Remember to actually *READ* the README file!
> Especially if you have any problems.
> ORACLE_HOME environment variable (c:Orant=) not valid.
> -----------
>
> Cheers!
>
> Gavin
------------------------------
Date: Sun, 18 Oct 1998 20:05:46 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Perl DBI AND Oracle (ORACLE_HOME)
Message-Id: <slrn72kigq.gf2.adelton@aisa.fi.muni.cz>
On Sun, 18 Oct 1998 20:24:30 +0100, Gavin Kuiper <gk@clara.net> wrote:
>
> I have been trying to setup the DBI modules to access a remote Oracle
> server. Basically, I have followed all of the steps to make the DBI
> modules, however, I am having a problem - when I try to make the Oracle DBM
> module - it keeps asking for an ORACLE_HOME environment variable to be set.
> This would be easy if the Oracle server was on the same machine - but it is
> on a remote machine on the LAN!
>
> My question is: How to I set this variable to reference a remote Oracle
> installation (If it is even possible)?
My answer might not be acurate because I never did an Oracle remote
access, but: you need some kind of Oracle software on the local
(client) machine (it's called something like SQL*Net). You cannot
access the remote Oracle server without it (unless you use DBD::Proxy,
but that's another story).
So you set ORACLE_HOME to directory containing this client software on
the local machine.
Hope this helps,
------------------------------
Date: Sun, 18 Oct 1998 23:28:47 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl-program binary
Message-Id: <PQuW1.4$O34.948@nsw.nnrp.telstra.net>
In article <36273994.558B5BE0@sw-systemekarlhickl.de>,
Dmitri Levitin <dmitri@sw-systemekarlhickl.de> writes:
> Dmitri Levitin wrote:
> I would like my users on unix SysV to be able to run my Perl-script with
> set -UID. This means i must set s-bit to my Perl-script and i can make this
> only if the script is compiled to a binary code. That's why i need
> something like 'c-compiler' for perl.
You should first read the perlsec documentation, which will explain
that you can write a 'c-wrapper' for your perl script.
# perldoc perlsec
If you have perl5.005, you could give the perlcc a try. It's
experimental, but might work for you.
# perldoc perlcc
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd. | things get worse.
NSW, Australia |
------------------------------
Date: 18 Oct 1998 23:21:39 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: snowe@rain.org (Nick Halloway)
Subject: Re: problems calling procmail
Message-Id: <m3iuhhbm70.fsf@joshua.panix.com>
snowe@rain.org (Nick Halloway) writes:
> close( COMMAND );
You must check the success of close() when you're "closing" a process.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 18 Oct 1998 22:44:11 GMT
From: "Garry T. Williams" <garry@america.net>
Subject: Re: problems calling procmail
Message-Id: <362A6F99.7894C613@america.net>
Jonathan Feinberg wrote:
>
> snowe@rain.org (Nick Halloway) writes:
>
> > close( COMMAND );
>
> You must check the success of close() when you're "closing" a process.
... and you will not know that the file system filled up (or other
disastrous things), if you don't check the results of a close on a
file.
-Garry Williams
------------------------------
Date: Sun, 18 Oct 1998 23:16:34 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
Subject: Re: Raleigh.pm (Raleigh, NC, USA perl mongers) has registered
Message-Id: <362A68C2.DD29061D@whiterabbit.co.uk>
Daniel Grisinger wrote:
> No, non-geeks are expected to RTFM if they are
> hungry :-).
Read the flipping menu
--
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: 18 Oct 1998 23:12:20 GMT
From: Alexis Huxley <alexis@danae.demon.co.uk>
Subject: Re: Slow Sort?
Message-Id: <f11psk.7et@danae.demon.co.uk>
I wrote:
> AH> Phew! I'm glad I'm not the only person encountering this! I have only
> AH> 20Mb and have a hash of structures with 27000 elements to sort on key
> AH> and it's taking 30 minutes.
In <x74st2tt6p.fsf@sysarch.com> Uri Guttman <uri@sysarch.com> writes:
> as the other guy was asked, please show us some of this sort code. maybe
Ok.
I have a hash %attribs containing structured records detailing various
file attributes. This is indexed on device and inode number as returned
by stat() (or lstat() for symlinks).
I have a second hash %names containing only the name of a file (or
whatever), which is indexed on device, inode number *and* the instance
of item pointing to the file data (i.e. hardlink number).
Having built the hashes, I then output the attributes for each filename
with this bit of code:
foreach $key (sort {$main::names{$a} cmp $main::names{$b}} (keys %main::names)) {
($dev, $inode, $i) = split($;, $key);
# output all interesting information except list of other links.
printf $out_handle "%s$main::field_separator%s$main::field_separator%d$main::field_separator%d$main::field_separator%o$main::field_separator%d$main::field_separator%s", $main::names{$key}, $main::attribs{$dev,$inode}->{type}, $main::attribs{$dev,$inode}->{uid}, $main::attribs{$dev,$inode}->{gid}, $main::attribs{$dev,$inode}->{mode}, $main::attribs{$dev,$inode}->{nlink}, $main::attribs{$dev,$inode}->{contents};
# If there are other links then also list them all except the
# one by which we're listing it of course!
if ($main::attribs{$dev,$inode}->{namecnt} != 1) {
for ($j=0; $j<$main::attribs{$dev,$inode}->{namecnt}; $j++) {
if ($j != $i) {
print $out_handle "$main::field_separator$main::names{$dev, $inode, $j}";
}
}
}
print $out_handle "$main::record_separator";
}
The code immediately before this builds the hashes, and this procedure
is heavily I/O bound. But when it hits this sort, the whole thing slows
right down and Linux's kswapd goes up the 'top' chart. This sort takes
30-40 minutes. Now admittedly, I only have 20Mb in my PC - as I mentioned
before - but if I send the data to Unix sort(1) then it's accomplished
in just a minute.
In case you're curious what this program is for, it's
a version of pdfck for Linux. The entire sources are at
http://www.danae.demon.co.uk/software/fad/.
If you can shed any light on why it's taking so long then I'd be very
grateful!
(I assumed it was because the sort would be trawling from one end of
the hash to the other constantly, and since it's a hash, rather than a
normal array, there isn't any guarantee that the data for the record with
the next key up in the collating sequence is anywhere near the current
record's data, thus exascerbating the 'trawling' even more. Of course
that might be a load of rubbish; I'm just trying to find some explanation
of the behaviour I see, while not being familiar with the perl internals.)
Alexis
--
Alexis Huxley
alexis@danae.demon.co.uk
email key: 549812
------------------------------
Date: 18 Oct 1998 18:15:43 -0500
From: monson@tri.sbc.com (Steve Monson)
Subject: Re: Slow Sort?
Message-Id: <70dsqv$9l6@euphony.tri.sbc.com>
See ye here Uri Guttman 's writings:
>as the other guy was asked, please show us some of this sort code. maybe
>you are doing something grossly wrong that can be fixed directly. we
>can't tell why only you two see 30 minute sorts. even in a thrashing
>system you should go much faster than that. virtual memory is slower
>than ram but not by such a margin. this tells me the sort routines and
>data structures are probably at fault.
I brought up the original problem. As I mentioned in my post, I
am not doing a sort of some convoluted structure. I have performed
a few computaional sections, and ended up with a list @s containing
102,442 small integers (ranging from 1 to about 100 or so). The
single line which took over 40 minutes was
@s = sort {$b <=> $a} @s;
I am currently doing a bit of checking to see why my program is taking
up so much memory (the raw data is only 6MB or so, but by the time I
get to this sort (having built some hash tables on the way), 28MB
is in use), and where I can put the sort to run in the 10-15 seconds
which it should take.
I'll get back to the ng when I turn something up.
Steve Monson
--
A woman drove me to drink and I didn't even have the decency to thank her.
-- W.C. Fields
------------------------------
Date: Sun, 18 Oct 1998 20:38:00 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: Storing object attributes in a DB_HASH?
Message-Id: <m3lnmdty23.fsf@perrin.dimensional.com>
Jeffery Cann <jc_cann@ix.netcom.com> writes:
> Given an object that stores its attributes as a hash:
>
> my $obj = {
> key1 = value1,
> key2 = value2,
> ...
> };
> bless ($obj,$pkg);
>
> I would like to store the attributes for $obj in a DB_HASH DB_File.
I think this is an interesting idea. It seems to me that it would
enable a more flexible method of persistence than what is currently
provided by Data::Dumper. Kind of like pickle in Python, but with
less programmer effort to manage the storage.
> The only way I can think of doing this is:
>
> 1. Concatenate the values of the hash into a single, comma-separated
> string:
> $rec="value1,value2";
I'd look at using Data::Dumper to create the stringified object. No
point reinventing an already well done wheel. Data::Dumper will also
properly handle self-referential data structures.
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
Support grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: 18 Oct 1998 23:23:57 GMT
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: Storing object attributes in a DB_HASH?
Message-Id: <01bdfaef$7150f260$77ea1286@steelres-pcm657.resmel.bhp.com.au>
Do you need to use DB_HASH?
If not, then MLDBM (Multi-level DBM) stores hash keys & values simply.
See Advanced Perl Programming by Sriram Srinivasan by O'Reilly, ISBN
1-56592-220-4, p 160.
Or ask me - I've written a program which stores a list of installed modules
in MLDBM.
--
Ron Savage
Home (preferred): rpsavage@ozemail.com.au
Office: Savage.Ron.RS@bhp.com.au
http://www.ozemail.com.au/~rpsavage
Jeffery Cann <jc_cann@ix.netcom.com> wrote in article
<36290567.48189EF@ix.netcom.com>...
> Hello.
>
> Given an object that stores its attributes as a hash:
>
> my $obj = {
> key1 = value1,
> key2 = value2,
> ...
> };
> bless ($obj,$pkg);
>
> I would like to store the attributes for $obj in a DB_HASH DB_File.
------------------------------
Date: Sun, 18 Oct 1998 23:12:49 +0100
From: Matt Pryor <matt@whiterabbit.co.uk>
To: Michael Rubenstein <miker3@ix.netcom.com>
Subject: Re: sub and return
Message-Id: <362A67E1.5534701F@whiterabbit.co.uk>
Ooops... I'd also have used strict if I'd given it a little more
thought.
Matt
Michael Rubenstein wrote:
>
> On Sat, 17 Oct 1998 19:42:33 +0100, Matt Pryor
> <matt@whiterabbit.co.uk> wrote:
>
> >#!/usr/bin/perl -w
> >
> >while ($repeat ne "no") {
> > print "Enter the radius of the circle. ";
> > $radius = <STDIN>;
> > chomp ($radius);
> > $circumference = ((2 * 3.1415)* $radius);
> > print "$circumference\n";
> > print "Do you want to try again? yes or no? ";
> > chomp($repeat=<STDIN>);
> >}
>
> It's very nice to use -w in examples for beginners. They should learn
> to use the option. It would be even nicer if the example did not
> cause a warning :-)
>
> $repeat = "";
>
> before the loop will fix it.
> --
> Michael M Rubenstein
--
Matt's daily comic strip
Porridge and Fartcakes
http://www.whiterabbit.co.uk/cartoons
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4004
**************************************