[22369] in Perl-Users-Digest
Perl-Users Digest, Issue: 4590 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 20 03:05:50 2003
Date: Thu, 20 Feb 2003 00:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 20 Feb 2003 Volume: 10 Number: 4590
Today's topics:
Re: A simple problem befuddling my simple head <jurgenex@hotmail.com>
Re: Also religious: brackets <REMOVEsdnCAPS@comcast.net>
Re: Also religious: brackets <newsfeed2@boog.co.uk>
Re: Also religious: brackets (Stefan Adams)
Re: Also religious: brackets <shondell@cis.ohio-state.edu>
ANNOUNCE: CGI::Explorer V 2.00 <ron@savage.net.au>
ANNOUNCE: Module::MakeDist V 1.04 <ron@savage.net.au>
ANNOUNCE: OpenInteract 1.56 released <chris@cwinters.com>
Re: Check for occurrence of element in Array (Jay Tilton)
Re: Having problems writing a tar file. Correction <bwalton@rochester.rr.com>
Re: Having problems writing a tar file. Correction <justinagraham@hotmail.com>
Re: Having problems writing a tar file. Correction <justinagraham@hotmail.com>
Re: Having problems writing a tar file. Correction <justinagraham@hotmail.com>
Re: How do I get the current date? <jurgenex@hotmail.com>
Re: How do I get the current date? (Sam Holden)
Re: How do I get the current date? <mr@sandman.net>
Re: Is "123abc" a number? (John Brock)
Re: Is "123abc" a number? <jurgenex@hotmail.com>
Re: Is "123abc" a number? <goldbb2@earthlink.net>
Re: Newbie Q re form to mail script FormProcessorPro (Jay Tilton)
Re: pipe() + fork() + exit() == problem? <gordan@_NOSPAM_bobich.net>
Re: reading excel spreadsheet with perl <bart.lateur@pandora.be>
Re: Religious question: commenting <mr@sandman.net>
Re: Removing HTML tags. <bart.lateur@pandora.be>
Report physical RAM of a remote PC <sapbasis2003@netscape.net>
Re: Report physical RAM of a remote PC <bigiain@mightymedia.com.au>
Re: Subroutine does not 'see' parameter passed to it (Jay Tilton)
Re: use DBI; <bart.lateur@pandora.be>
Re: using tar.bz2 <bwalton@rochester.rr.com>
When is perl6 expected to be available? (Hiroki Horiuchi)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Feb 2003 02:35:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: A simple problem befuddling my simple head
Message-Id: <Y9X4a.29428$wH5.21519@nwrddc04.gnilink.net>
Liam James wrote:
> I am just learning PERL,
Did you mean 'Perl'?
> and I am trying to set up a simple validation
> script, it checks to set that the content of one edit box is the same
> as another.
Perl does not have edit boxes.
> Its similar to 'choose a password - now confirm it'. No
> matter what I do I keep getting a 500 error.
I' guessing this is a stealth CGI question.
In that case you should follow the advise given in the FAQ: perldoc -q 500
> So far I have :
[...]
> If ($email1 eq $email2)
Upper case 'If'? Maybe you meant 'if'?
If you would have tested your script from the command line then the perl
parser would have told you about this bug already and you would have never
had to guess about some obscure 500 error.
jue
------------------------------
Date: Wed, 19 Feb 2003 20:33:56 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Also religious: brackets
Message-Id: <Xns9327DB5F85753sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Sandman <mr@sandman.net> wrote in
news:mr-DD6C65.23345619022003@news.fu-berlin.de:
> How do you use brackets in your code in loops or if statements?
Here
...
> Any other variations you prefer? I am a #1 guy myself, but use #2
if
> the do's are one-liners.
I greatly prefer
if (something)
{
statement;
}
else
{
statement;
}
Imho, I find it very neat and easy to follow if all the brackets line
up with their respective constructs.
But when posting code to usenet, or in email, I often do
if (something) {
statement;
}
else {
statement;
}
in order to make the code more compact.
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+VD6PY96i4h5M0egRAsO+AJ9wqBArb0xJwppt6fD/DQXt+MHBnACfee3i
69rvwxohw+uyHPd6wOIbRW8=
=bVCG
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 20 Feb 2003 03:22:20 -0000
From: "Peter Cooper" <newsfeed2@boog.co.uk>
Subject: Re: Also religious: brackets
Message-Id: <CSX4a.2134$jy1.17118@newsfep4-glfd.server.ntli.net>
> One-liners goes like this;
>
> do if ( statement );
If I have a 'debug' or verbose switch in a program I tend to implement it like
so:
$debug && print $variable;
Pete
------------------------------
Date: 19 Feb 2003 20:56:41 -0800
From: stefan@borgia.com (Stefan Adams)
Subject: Re: Also religious: brackets
Message-Id: <dcc927de.0302192056.520fe431@posting.google.com>
Sandman <mr@sandman.net> wrote in message news:<mr-DD6C65.23345619022003@news.fu-berlin.de>...
> How do you use brackets in your code in loops or if statements? Here are some
> versions I can come up with:
Here's how I do it:
if ( statement ) {
do ...
} else {
do ...
}
------------------------------
Date: 20 Feb 2003 00:09:30 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Also religious: brackets
Message-Id: <xcw7kbvpmgl.fsf@psi.cis.ohio-state.edu>
"Peter Cooper" <newsfeed2@boog.co.uk> writes:
> > One-liners goes like this;
> >
> > do if ( statement );
>
> If I have a 'debug' or verbose switch in a program I tend to
> implement it like so:
>
> $debug && print $variable;
Wow, that's almost a carbon-copy example of what perlstyle says _not_
to do, because it hides the main point of the statement.
--
Ryan Shondell <shondell@cis.ohio-state.edu>
------------------------------
Date: Mon, 17 Feb 2003 19:40:48 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: CGI::Explorer V 2.00
Message-Id: <3e53d252$1_5@news.teranews.com>
CGI::Explorer V 2.00 is a pure Perl module, available immediately
from CPAN or from http://savage.net.au/Perl-modules.html.
Abstract: A CGI support module for tree management and display.
Here is an excerpt from the change log:
2.00 Tue Dec 10 20:05:00 2002
- Note: The API for V 2 has nothing in common with the API for V 1
- Rewrite to use xtree by Emil A Eklund http://webfx.eae.net/
This means mouse clicks which expand and contract sub-trees
are handled by JavaScript in the client, and so do not need
to send a message on a round trip to the server and back
- Ship Eklund's files xtree.css and xtree.js
- Use Eklund's files for the images, too, and 3 extra images (see POD)
- Ship a demo, hobbit-hash.cgi, which displays a hash tree.
This script does not require any other modules
- Ship a demo pair, bootstrap-hobbit.pl which creates a database table, and
hobbit.cgi which reads and displays a database table as a hash tree.
These 2 scripts require DBIx::Hash2Table and DBIx::Table2Hash
- Document how to use hobbit.cgi as an Apache V 2 script
- Add a trivial test script t/test.t, which is actually a copy of test.pl
- Rewrite the documentation
------------------------------
Date: Mon, 17 Feb 2003 19:42:32 +1100
From: "Ron Savage" <ron@savage.net.au>
Subject: ANNOUNCE: Module::MakeDist V 1.04
Message-Id: <3e53d242$2_1@news.teranews.com>
Module::MakeDist V 1.04 is a pure Perl module, available immediately
from CPAN or from http://savage.net.au/Perl-modules.html.
Abstract: Convert module into shippable files (*.tgz, *.zip).
Here is an excerpt from the change log:
1.04 Mon Feb 17 10:04:00 2003
- Patch to stop shipping blib/ directory in Unix distros, because the
PAUSE indexer takes this directory to indicate a binary distro,
which means it does not index the module, and this in turn means
the module is not listed in the CPAN daily update list, etc.
Procedure:
o Create Unix-style distro *.tgz
o Create helper file *.tar.gz. You can ignore this file
o Create PPM-style distro *.zip, which contains *.tar.gz
------------------------------
Date: Mon, 17 Feb 2003 22:58:09 -0500
From: Chris Winters <chris@cwinters.com>
Subject: ANNOUNCE: OpenInteract 1.56 released
Message-Id: <3e53d226$1_7@news.teranews.com>
A new version (1.56) of OpenInteract has been released. OpenInteract
is an extensible web application server built on Apache, mod_perl, the
Template Toolkit and SPOPS object persistence.
This is a fairly minor upgrade. There are some changes to the INI
configuration reader, documentation updates to a number of packages, a
fix so that the (rare) package repository corruption shouldn't happen,
and a few other enhancements and bugfixes.
Source:
http://prdownloads.sourceforge.net/openinteract/OpenInteract-1.56.tar.gz?download
Detailed changes:
http://sourceforge.net/project/shownotes.php?group_id=16810&release_id=140942
I'll release it to PAUSE when the main CPAN mirror gets over its
recent difficulties.
Thanks!
Chris
--
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.
------------------------------
Date: Thu, 20 Feb 2003 03:56:10 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Check for occurrence of element in Array
Message-Id: <3e5450c6.78184168@news.erols.com>
Shane McDaniel <shanem@nospam.ll.mit.edu> wrote:
: Tad McClellan wrote:
:
: > my %tld;
: > $tld{de} = 1;
: > $tld{en} = 1;
: > $tld{fr} = 1;
: >
: > if ( $tld{$isocode} )
: > { print "found $isocode\n" }
: > else
: > { print "$isocode not found\n" }
: >
:
: Isn't the exist() function the better way to check for existance?
It is when an element can have a non-true value, and the element's
existence is what matters.
Makes no difference in that code. If an element exists, its value
will be true.
Don't quote sigs.
------------------------------
Date: Thu, 20 Feb 2003 03:02:00 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E544515.1010500@rochester.rr.com>
Justin A. Graham wrote:
...
> I am trying to tar a list of file with the following snippet;
>
> # Archive files
> $tar = Archive::Tar->new();
> $tar->add_files(@files);
> $tar->write($filename);
>
> @files and $filename are valid...
>
> The result is the tar file $filename filled with zeroes.
>
> What am I doing wrong?
...
> Justin
Are you sure? Your snippet works fine for me when I fill it out. The
resulting TAR file can be interpreted as basically what you claim in
either of your notes: all your files concatendated together (with a bit
of binary gibberish, mostly null bytes, inbetween; or, if you happen to
examine the end of the file, you might conclude it was all null bytes.
The file is actually a perfectly valid TAR file, though. HTH.
--
Bob Walton
------------------------------
Date: Thu, 20 Feb 2003 05:18:28 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E546531.9040307@hotmail.com>
Ron Reidy wrote:
> perldoc Archive::Tar shows the write() metjod takes 2 arguments. Did
> you try it this way?
>
> --
> Ron Reidy
> Oracle DBA
>
I'll give it a try...
------------------------------
Date: Thu, 20 Feb 2003 05:21:29 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E546585.8050709@hotmail.com>
Bob Walton wrote:
> Justin A. Graham wrote:
>
> ...
>
>> I am trying to tar a list of file with the following snippet;
>>
>> # Archive files
>> $tar = Archive::Tar->new();
>> $tar->add_files(@files);
>> $tar->write($filename);
>>
>> @files and $filename are valid...
>>
>> The result is the tar file $filename filled with zeroes.
>>
>> What am I doing wrong?
>
> ...
>
>
>> Justin
>
>
> Are you sure? Your snippet works fine for me when I fill it out. The
> resulting TAR file can be interpreted as basically what you claim in
> either of your notes: all your files concatendated together (with a bit
> of binary gibberish, mostly null bytes, inbetween; or, if you happen to
> examine the end of the file, you might conclude it was all null bytes.
> The file is actually a perfectly valid TAR file, though. HTH.
>
Very sure. The file is too small, and is entirely null. I am about to
try passing in the second param which has to do with compression I believe.
Thanks
Justin
------------------------------
Date: Thu, 20 Feb 2003 05:56:39 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: Re: Having problems writing a tar file. Correction
Message-Id: <3E546DE7.50604@hotmail.com>
Bob Walton wrote:
> Justin A. Graham wrote:
>
> ...
>
>> I am trying to tar a list of file with the following snippet;
>>
>> # Archive files
>> $tar = Archive::Tar->new();
>> $tar->add_files(@files);
>> $tar->write($filename);
>>
>> @files and $filename are valid...
>>
>> The result is the tar file $filename filled with zeroes.
>>
>> What am I doing wrong?
>
> ...
>
>
>> Justin
>
>
> Are you sure? Your snippet works fine for me when I fill it out. The
> resulting TAR file can be interpreted as basically what you claim in
> either of your notes: all your files concatendated together (with a bit
> of binary gibberish, mostly null bytes, inbetween; or, if you happen to
> examine the end of the file, you might conclude it was all null bytes.
> The file is actually a perfectly valid TAR file, though. HTH.
>
I should probably add that I am testing this on my windows development
machine, where the archiving will occur. Perhaps there is something
funky with the windows implementation of archive::tar
Justin
------------------------------
Date: Thu, 20 Feb 2003 02:43:02 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How do I get the current date?
Message-Id: <WgX4a.42962$rE3.18033@nwrddc01.gnilink.net>
Sandman wrote:
> In article <x7wujwq8y0.fsf@mail.sysarch.com>,
> Uri Guttman <uri@stemsystems.com> wrote:
>>> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
>>> (localtime)[3], (localtime)[5]+1900);
>>
>> what if those calls to localtime just happen to straddle the interval
>> between an hour, day or even month?
>
> And what if a meteor crashes into his house at the same time.
Won't affect the program execution because it is run by dozen of people all
over the world (hopefully not!)
If you don't understand the difference between a bug caused by careless
coding and a singular external event then you may want to consider changing
your profession.
jue
------------------------------
Date: 20 Feb 2003 03:48:04 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: How do I get the current date?
Message-Id: <slrnb58jvk.ts1.sholden@flexal.cs.usyd.edu.au>
On Wed, 19 Feb 2003 22:35:46 +0100, Sandman <mr@sandman.net> wrote:
> In article <x7wujwq8y0.fsf@mail.sysarch.com>,
> Uri Guttman <uri@stemsystems.com> wrote:
>
>> cc'ed to the OP so he doesn't use this bad code.
>>
>> >>>>> "S" == Sandman <mr@sandman.net> writes:
>>
>> S> In article <3E53E86F.2090803@hotmail.com>,
>> S> "Justin A. Graham" <justinagraham@hotmail.com> wrote:
>>
>> >> I want to write a script that zip up files, and names the archive
>> >> file-month-day-year.zip
>> >>
>> >> How do I get the current date in a perl script?
>>
>> S> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
>> S> (localtime)[3], (localtime)[5]+1900);
>>
>> GACK!!
>>
>> what if those calls to localtime just happen to straddle the interval
>> between an hour, day or even month?
>
> And what if a meteor crashes into his house at the same time.
I have been living in houses for a number of years, I don't know of one
instance of a meteor crashing into one of them. Hence I figure the odds
are pretty low. More importantly there's nothing I can do to protect
my code from such an event.
In the time I've been living in said houses, the hour has changed about
24 times every day. There has not been a single day in which the hour
hasn't changed. Hence I figure the odds of the hour changing to be
significantly higher. More importantly I can trivially make my code
immune to errors from such changes.
--
Sam Holden
------------------------------
Date: Thu, 20 Feb 2003 07:50:13 +0100
From: Sandman <mr@sandman.net>
Subject: Re: How do I get the current date?
Message-Id: <mr-40DDB8.07501320022003@news.fu-berlin.de>
In article <WgX4a.42962$rE3.18033@nwrddc01.gnilink.net>,
"Jürgen Exner" <jurgenex@hotmail.com> wrote:
> >> what if those calls to localtime just happen to straddle the interval
> >> between an hour, day or even month?
> >
> > And what if a meteor crashes into his house at the same time.
>
> Won't affect the program execution because it is run by dozen of people all
> over the world (hopefully not!)
>
> If you don't understand the difference between a bug caused by careless
> coding and a singular external event then you may want to consider changing
> your profession.
It was a joke, relax and have a popsicle. :)
--
Sandman[.net]
------------------------------
Date: 19 Feb 2003 22:34:54 -0500
From: jbrock@panix.com (John Brock)
Subject: Re: Is "123abc" a number?
Message-Id: <b31icu$1n2$1@panix1.panix.com>
In article <b30m5a$hp7$3@mamenchi.zrz.TU-Berlin.DE>,
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>John Brock <jbrock@panix.com> wrote in comp.lang.perl.misc:
>> In Perl 5.004 I find that the statement
>>
>> $x = "123abc" / 2;
>>
>> sets $x to 61.5. Is this a feature?
>That depends on your point of view.
>> Testing with other values
>> the rule seems to be treat a string as a number up until you hit
>> a character which cannot be interpreted as part of a number, and
>> then ignore everything from there on (note that with the -w flag
>> I do get a warning message). This would be useful to me if I knew
>> I could count on it, but I did a quick search of Programming Perl
>> (3rd Edition) and I couldn't find this behavior described. Is this
>> an official part of the language?
>I think it's described somewhere, though I can't find it in a hurry.
>It is best not to use the feature (if that's what it is), simply
>because it's not warning-safe. Try your code with switched-on
>warnings and see. So it's no good for general consumption.
>
>If you really think you must use it, put the operation in a small
>block, and disable only this warning with "no warnings 'numeric'".
I regularly take advantage of the fact that null strings evaluate
as zero in a numeric context, and this definitely seems like a well
documented and useful feature, so I have no hesitation about using
the behavior I described, which seems like a natural extension.
But it kind of disturbs me that I can't find this behavior documented
in Programming Perl, which I had understood to be the Perl Bible.
Programming Perl does say that the conversion is done by a function
"something like" atof(3), and when I looked up the man page for
atof(3) it seemed consistent what what I observed. Still, I would
hope that a serious language like Perl has a rigorous definition
somewhere for numbers and numeric behavior, and doesn't just
haphazardly implement a convenient C function.
--
John Brock
jbrock@panix.com
------------------------------
Date: Thu, 20 Feb 2003 05:12:08 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Is "123abc" a number?
Message-Id: <IsZ4a.15702$_k4.9477@nwrddc03.gnilink.net>
John Brock wrote:
> Is "123abc" a number?
No, it is not a number. But it has a numerical value associated to it.
jue
------------------------------
Date: Thu, 20 Feb 2003 01:03:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Is "123abc" a number?
Message-Id: <3E546F9E.1D5B1FC@earthlink.net>
John Brock wrote:
>
> In article <b30m5a$hp7$3@mamenchi.zrz.TU-Berlin.DE>,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >John Brock <jbrock@panix.com> wrote in comp.lang.perl.misc:
> >> In Perl 5.004 I find that the statement
> >>
> >> $x = "123abc" / 2;
> >>
> >> sets $x to 61.5. Is this a feature?
>
> >That depends on your point of view.
>
> >> Testing with other values
> >> the rule seems to be treat a string as a number up until you hit
> >> a character which cannot be interpreted as part of a number, and
> >> then ignore everything from there on (note that with the -w flag
> >> I do get a warning message). This would be useful to me if I knew
> >> I could count on it, but I did a quick search of Programming Perl
> >> (3rd Edition) and I couldn't find this behavior described. Is this
> >> an official part of the language?
>
> >I think it's described somewhere, though I can't find it in a hurry.
> >It is best not to use the feature (if that's what it is), simply
> >because it's not warning-safe. Try your code with switched-on
> >warnings and see. So it's no good for general consumption.
> >
> >If you really think you must use it, put the operation in a small
> >block, and disable only this warning with "no warnings 'numeric'".
>
> I regularly take advantage of the fact that null strings evaluate
> as zero in a numeric context, and this definitely seems like a well
> documented and useful feature, so I have no hesitation about using
> the behavior I described, which seems like a natural extension.
> But it kind of disturbs me that I can't find this behavior documented
> in Programming Perl, which I had understood to be the Perl Bible.
> Programming Perl does say that the conversion is done by a function
> "something like" atof(3), and when I looked up the man page for
> atof(3) it seemed consistent what what I observed. Still, I would
> hope that a serious language like Perl has a rigorous definition
> somewhere for numbers and numeric behavior, and doesn't just
> haphazardly implement a convenient C function.
In older perls, it just used atof(3) directly.
Modern perl (5.8) has it's own conversion utility for this, which tries
to preserve integer-ness or unsigned-integer-ness, and only producing a
double if it needs to.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: Thu, 20 Feb 2003 04:08:31 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Newbie Q re form to mail script FormProcessorPro
Message-Id: <3e545312.78772849@news.erols.com>
<notworking@all.com> wrote:
: While busily concocting a devastating reply tiltonj@erols.com retorted
: > Trilby <notworking@all.com> wrote:
: >
: > : I am not a perl programmer but trying to deal with a perl script called
: > : FormProcessorPro v3.2 [Mitridat.com] which takes the contents of a html
: > : form and emails it to recipients in a format based on templates that the
: > : user can set out in a txt file with whatever text is required and the
: > : fields from the form in brackets [ ].
: > :
: > : I am hoping you can help me with a small matter:
: >
: > Was the program vendor unable or unwilling to help?
: >
: Unfortunately they don't offer a user forum and I can't find any
: references to it on the web, even though I think it's a great script.
: He does offer help from time to time but at great delay and at a cost.
:
: Do I take it that there is no 'obvious' solution ?
No idea. It may be obvious to someone familiar with the package,
which Perl programmers are evidently not. Not many will go to the
trouble of acquiring and studying a package to debug somebody else's
hangup. Not for free, anyway.
Best guess, and it's a real WAG, is there's some CRLF mistranslation
going on when the template is uploaded onto the server.
------------------------------
Date: Thu, 20 Feb 2003 07:28:46 +0000
From: Gordan <gordan@_NOSPAM_bobich.net>
Subject: Re: pipe() + fork() + exit() == problem?
Message-Id: <1045726130.38008@auth2.dns.griffin.net.uk>
Benjamin Goldberg wrote:
>
>
> gordan@_NOSPAM_bobich.net wrote:
>>
>> Hi!
>>
>> Got a small problem. I'm trying to write an application that
>> regulates the number of forked children according to it's outstanding
>> workload (within limits, obviously).
>>
>> I use pipes to communicate the process queue between the queue
>> process and the worker processes. There is one pipe for writing to
>> the queue, and one pipe for the forked worker threads to read from.
>> This method works very nicely, and I'd like to keep it.
>
> Are you *sure* that it works nicely?
Yes. I'm using the method that is pretty much pasted from the example
you gave me some time ago. :-)
It never skipped a beat in anything else I did using that method...
> Are you performing locking on
> the queue?
On the worker side, yes. I use flock. I don't bother locking on the
queue process side because the queue is the only thing that reads from
the input queue and the only thing that writes to the output queue.
> What keeps more than one worker from reading at once?
flock (InputQueueWrite, LOCK_EX);
and
flock (OutoutQueueRead, LOCK_EX);
> Also, what perl primitive are you using to read data from the queue?
> If you're using any of read(), readline(), or <>, then each worker is
> performing input-buffering, and may be reading more than just one
> job-- it may be getting a job and a half, or somesuch (leaving half a
> job in the queue, which will be seen by another worker as corrupted
> data).
I use read(). There are not data corruptions. I have $| = 1 set for all
pipes.
> I'd be willing to bet that if you were to add locking (either via
> flock($rd, LOCK_EX) or via a second pair of pipes), and change your
> reading of jobs to use sysread(), then the problem will go away.
OK, let me try using sysread() instead or read() as that is the only
thing not already being done...
OK, I'm feeling really stupid now. That works fine.
If I was having problems caused by buffering that read() does, then how
come none of the data in the pipe was ever getting corrupted when
multiple threads were reading/writing that pipe? There are thousands of
things going in and out of the pipes, so I'm not convinced I was just
being lucky...
Thanks.
Gordan
------------------------------
Date: Thu, 20 Feb 2003 07:42:49 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: reading excel spreadsheet with perl
Message-Id: <9m195voip8p3j12bck2d9n17bbo92d68pu@4ax.com>
Bob Dubery wrote:
>Recent versions of Excel can ouput spreadsheets as XML,
Does that option preserve text formatting?
--
Bart.
------------------------------
Date: Thu, 20 Feb 2003 07:44:55 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Religious question: commenting
Message-Id: <mr-3A4490.07445320022003@news.fu-berlin.de>
In article <b313rc$9la$1@nets3.rz.RWTH-Aachen.DE>,
"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote:
> > if ($in{who}){ $who = $in{who}; } # default is $in{who}
> > if ($in{name}){ $who = $in{name}; } # but $in{name} overwrites
> > if ($in{person}){ $who = $in{person}; } # as does $in{person}
> >
> > These comments are redundant, since the code clearly shows that this
> > is what happens. But when these three lines are found in the middle of
> > a lengthy script, another reader might ask "Why is he doing this? Is
> > this his intention? All it does is overwrite the variable..." - That
> > reader sees, by reading the comment, that that is indeed my intention.
>
> The above code should have never been written. A good example how clear
> code can make comments obsolete. Typically the above would change to:
>
> $who ||= $in{person} || $in{name} || $in{who};
>
> After all, this is what the ||= and || operators are for. Only a little
> familiarity with those is needed to understand immediately what's going
> on whereas I find the above if-chain harder to follow (the comment wont
> necessarily turn it into nice code).
Sigh. It was an example. Stop focusing on the -code-. Or are you claiming that
the above example is totally invalid, and it doesn't illustrate a situation
where redundant commenting would be useful?
> > Or what if I have a foreach() like this:
> >
> > foreach (keys %fields){
> > print "$field{$_}<br>\n";
> > push @values, $_; # save for later in array
> > }
> >
> > The above @values array may only be used this one time in the entire
> > program, but the comment illustrates how I've imagined that this
> > information might come in handy, so I put it in an array. And people
> > will know that I did so intentionally.
>
> I strongly suggest you remove code that doesn't do anything.
I strongly suggest you stop focusing on the code, and start talking about
commenting. This is a useless discussion. Sorry. I suppose this is what I get
for bringing up a topic as religious as this.
--
Sandman[.net]
------------------------------
Date: Thu, 20 Feb 2003 07:55:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Removing HTML tags.
Message-Id: <2s195v0mu9gads5tdcjls8aq84hedii476@4ax.com>
Tony McNulty wrote:
>Essentially, I'm writing an add-on for an irc bot that I wrote a little
>while ago. I'm attempting to get a page from the web, and then stripping
>the html tags from it to make it easier to extract the text that I need
>from it.
In general, for HTML processing, I would recommend
HTML::TokeParser::Simple. But basically, HTML::Parser will do as well.
See <http://www.gellyfish.com/htexamples/> for an gently intro to the
latter. Actually, the very first example extracts the plain text.
>I've just been browsing through the module lists on CPAN to see if there
>was any there to help with this, and only found one that applied to files
>only.
No, look again. HTML::TokeParser::Simple inherits from HTML::TokeParser
which inherits from HTML::Parser. So likely all three can parse the
same.
For HTML::Parser, the docs say:
$p->parse( $string );
Parse the $string as an HTML document. Can be called multiple
times. The return value is a reference to the parser object.
$p->parse_file( $file );
This method can be called to parse text from a file. The
argument can be a filename or an already opened file handle. The
return value from parse_file() is a reference to the parser
object.
For HTML::TokeParser (and for HTML::TokeParser::Simple):
$p = HTML::TokeParser->new( $file_or_doc );
The object constructor argument is either a file name, a file
handle object, or the complete document to be parsed.
If the argument is a plain scalar, then it is taken as the name
of a file to be opened and parsed. [...]
If the argument is a reference to a plain scalar, then this
scalar is taken to be the document to parse.
I don't know where you get the notion from that these can only parse
directly from files.
--
Bart.
------------------------------
Date: Wed, 19 Feb 2003 23:21:33 -0800
From: SAPBasis2003 <sapbasis2003@netscape.net>
Subject: Report physical RAM of a remote PC
Message-Id: <3E5481FD.10600@netscape.net>
How can I report the RAM of a remote PC?
Does anybody have a sample code to do this?
Thank you.
------------------------------
Date: Thu, 20 Feb 2003 19:00:06 +1100
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: Report physical RAM of a remote PC
Message-Id: <bigiain-007B04.19000620022003@nasal.pacific.net.au>
In article <3E5481FD.10600@netscape.net>,
SAPBasis2003 <sapbasis2003@netscape.net> wrote:
> How can I report the RAM of a remote PC?
> Does anybody have a sample code to do this?
> Thank you.
>
How about:
-----------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
require Mail::Send;
my $msg = new Mail::Send Subject=>'support request',
To=>'support@colocation.example.com';
my $fh = $msg->open;
print $fh <<END;
Hey guys,
Can you please reboot my server, and let me know
how much ram it reports as it boots?
Thanks!
SAPBasis2003
END
$fh->close;
-----------------------------------------------------------------
or maybe:
-----------------------------------------------------------------
#!/usr/bin/perl -w
use strict;
my $test;
while(1){
$test.='X';
print "you have at least $_ bytes of ram available\n";
}
-----------------------------------------------------------------
Real answer? You'll need to tell more about what you're trying to
achieve. Do you want to do this on Windows? Linux? Portably across loys
of "PC" platforms?
if its Linux,you could start woyj"
perl -e 'if(`dmesg` =~/Memory: (.*)/){print $1};'
cheers,
big (yes, I'm trying to be funny!)
------------------------------
Date: Thu, 20 Feb 2003 03:40:51 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Subroutine does not 'see' parameter passed to it
Message-Id: <3e544c80.77090747@news.erols.com>
georgem@crystalgraphics.com (george) wrote:
: Gunnar Hjalmarsson <noreply@gunnar.cc> wrote in message news:<mQy4a.704$ID6.2139@newsc.telia.net>...
: > george wrote:
: > > sub writeTrackRecord;
: > > {
: > >
: > > my $somevar = shift;
: > >
: > > ... does some stuff, and calls some other
: > > ... subroutines that are defined in this module.
: > > }
: > > ...
: > > Also, another very strange thing, is that in order for the subroutine
: > > to work, I need to put a ';' at the end of the subroutine name in the
: > > definition:
: >
: > With that semicolon, you just declare a subroutine name with the line
: > 'sub writeTrackRecord;'. The following block is then *not* part of the
: > subroutine, but just a separate block.
:
: Thanks for your response. There was no error message.
There should be.
The subroutine is not defined, only declared. When it's called, perl
should chirp about "Undefined subroutine &main::writeTrackRecord
called at ...".
Is there a subroutine by the same name defined somewhere else in the
program, or defined in another package and exported to your namespace?
Are you developing with warnings enabled?
: Without the
: semicolon, no record was written to the database. With the semicolon,
: then a record was written to the database -- so that is how I know
: that the subroutine was evolked.
That a record is written has nothing to do with the subroutine call.
Dike the "sub writeTrackRecord;" line and watch the record get written
anyway.
------------------------------
Date: Thu, 20 Feb 2003 08:04:00 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: use DBI;
Message-Id: <3m295v42f1algt4b733hakihp8aobpngsl@4ax.com>
Tassilo v. Parseval wrote:
>> Do you use exit(0) a lot? And if so, what for?
>
>I can't speak for Abigail, but I use it from time to time in various
>situations. Sometimes it's necessary, sometime's it's not.
I wish return() when used from the top level would just exit() without a
complaint. I'd prefer to use that.
Sometimes exit() is just too strong. As in:
my $code = <<'--';
print "I want this executed\n";
exit;
print "I want this skipped\n";
--
eval $code;
print "Finished!\n";
This snipped won't ever go beyond the eval(). Ouch.
Imagine using exit() in a mod_perl script.
<http://take23.org/docs/guide/porting.xml/13>
--
Bart.
------------------------------
Date: Thu, 20 Feb 2003 03:09:10 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: using tar.bz2
Message-Id: <3E5446C4.8020807@rochester.rr.com>
samphdauto wrote:
...
> I am having hard time understanding what is going on with this..
> I got Perl source code then got a C compiler gcc-3.2.2.tar.bz2 to
> compile it then I got a ziping software bzip2-102-x86-win32 to unzip
> the compiler then I don't know how to use this bzip2-102-x86-win32
...
> Sam
>
If you are working under W2K, save yourself a lot of grief and download
a precompiled Perl, like ActiveState Perl or Cygwin Perl. You can have
a working Perl in 5 minutes.
If you insist on compiling the Perl source, check out Cygwin as a way of
getting a working C compiler, which is step #1.
--
Bob Walton
------------------------------
Date: 19 Feb 2003 23:43:52 -0800
From: hiroki@air.ne.jp (Hiroki Horiuchi)
Subject: When is perl6 expected to be available?
Message-Id: <85c98cd5.0302192343.7f00ec4a@posting.google.com>
Hello folks.
When is perl6 expected to be available?
Thanks in advance.
///Hiroki Horiuchi
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 4590
***************************************