[8855] in Perl-Users-Digest
Perl-Users Digest, Issue: 2472 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 1 12:07:35 1998
Date: Fri, 1 May 98 09:00:29 -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 Fri, 1 May 1998 Volume: 8 Number: 2472
Today's topics:
Re: "use strict" complains about GetOptions variables (Andrew M. Langmead)
Re: 1701 days hath September (was: Re: rename funciton) (John Porter)
Re: 1701 days hath September (was: Re: rename funciton) (Chris Nandor)
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: 1701 days hath September (was: Re: rename funciton) (John Stanley)
Re: == vs. eq (Chris Nandor)
Re: Adding 600 users to a Linux password file <brianm@kodak.com>
alarm <buck@huron.net>
Any way to flush Perl output buffer <lwoolsey@innovative.ca>
Re: Any way to flush Perl output buffer <brianm@kodak.com>
Re: Any way to flush Perl output buffer (John Porter)
Code works on Unix, and MacPerl. Why not Win32? (Pamela Culpepper)
Re: comp.lang.perl.misc (was Re: Credit Card Verificati (John Porter)
Re: comp.lang.perl.misc (was Re: Credit Card Verificati <brianm@kodak.com>
Re: Credit Card Verification scripts? lvirden@cas.org
Re: email attachments <brianm@kodak.com>
Re: email attachments <quednauf@nortel.co.uk>
Re: Evaluation of hex character representation in doub (John Porter)
Re: Evaluation of hex character representation in doub <gmorgan@photogrpahics.co.uk>
Re: Evaluation of hex character representation in doub (John Porter)
fork problem (Dave Parkin)
need help with hashtable size/memory <hadley@globin.bio.warwick.ac.uk>
Re: Perl web server.... (Bart Lateur)
Re: Perl/Wall lingo question (John Porter)
Re: Perl/Wall lingo question <boys@aspentech.com>
Re: Perl/Wall lingo question (brian d foy)
Personal Web Server and Perl <nasarma@emirates.net.ae>
Re: Personal Web Server and Perl <brianm@kodak.com>
Re: Ref to an LVALUE??? I expected a simple SCALAR ref <eryq@zeegee.com>
Re: Ref to an LVALUE??? I expected a simple SCALAR ref (John Porter)
Re: Safest way to read from a socket? (Andrew M. Langmead)
seg fault when matching long string (PGS Fluendy)
Using executable pathname to define include path <glew@cs.wisc.edu>
Re: You people want Perl to be popular? (Chris Nandor)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 1 May 1998 14:01:22 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: "use strict" complains about GetOptions variables
Message-Id: <EsA6yA.HIv@world.std.com>
John Bossert <jbosser@ibm.net> writes:
>If I (per the Perl Bibles) specify "use strict;", perl complains about
>the "$opt_foo" variables I'm
>referencing within a GetOptions() call.
>How should I declare these variables so as to get past the "strict"
>enforcement? TIA.
According to the documentation that comes with the "strict" pragma,
(You can use the "perldoc" command or maybe the "man" command to read
it.) variables must be lexically local variables ("my()" variables) or
be fully qualified by their package name. A third option which it
doesn't mention is the "use vars" pragma, which exempts them from the
"use strict" pragma. Also, getOptions takes an optional hash to hold
the options instead of writing them to your packages namespace.
So, your choices are:
$main::opt_foo
use vars qw($opt_foo);
$opt_foo
or
%optctl = ("foo" => \$foovalue);
GetOptions(\%optctl, "foo=s");
$foovalue
--
Andrew Langmead
------------------------------
Date: Fri, 01 May 1998 14:11:18 GMT
From: jdporter@min.net (John Porter)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <MPG.fb3a39efaa7264198968e@news.min.net>
jdporter@min.net (John Porter) wrote:
>
> That's not a commonly help opinion.
^^^^
Wow. Freudian slip, or what?
------------------------------
Date: Fri, 01 May 1998 10:24:20 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <pudge-0105981024250001@ppp-5.ts-1.kin.idt.net>
In article <3547EDD6.2BBE@juicepigs.com>, Bob Trieger
<sowmaster@juicepigs.com> wrote:
# Moderation = censorship in my eye and all censorship is evil.
You have very odd definitions of both moderation and censorship.
Moderation only censors off-topic material; how that can be evil, or
considered "censorship" in the general case, I am unclear. Further, it is
voluntary. How a group of people agreeing to start a new "community"
under certain rules of communication where everyone is welcome and has a
voice can be evil is beyond me.
Similarly, censorship exists everywhere, in every thing where two or more
people are gathered. If censorship is evil, communication is evil.
Protocols and netiquette are evil. My router is evil because it won't let
certain packets pass through. My phone line is evil because it limits the
speed of my transmissions. That is censorship. You can't send
unsolicited commercial faxes to my fax machine. That is censorship.
Think on.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 1 May 1998 15:42:55 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6icqhv$dcu$1@news.NERO.NET>
In article <pudge-0105981024250001@ppp-5.ts-1.kin.idt.net>,
Chris Nandor <pudge@pobox.com> wrote:
>Moderation only censors off-topic material;
Even using the term in the less strict sense, moderation "censors"
whatever the moderator wants to "censor". There is no inherent limit to
what can be excluded, only trust that the moderator will not exclude
on-topic articles. In fact, moderators quite often "censor" on-topic
articles -- I have seen more than one saying "enough of that topic,
let's move on...".
And, since we seem to be using a very loose definition of the word, the
very existance of a moderator serves to censor, since some people will
not use a moderated group, and thus every on-topic article they would
have submitted is "censored".
Perhaps this serves as an example of why using a baggage-laden term like
censorship in such a loose way is not productive?
>How a group of people agreeing to start a new "community"
>under certain rules of communication where everyone is welcome and has a
>voice can be evil is beyond me.
This is the utopian view of the process. The proposal for a new perl
group does not quite meet this goal.
------------------------------
Date: 1 May 1998 15:47:33 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: 1701 days hath September (was: Re: rename funciton)
Message-Id: <6icqql$ddr$1@news.NERO.NET>
In article <MPG.fb38fbd4135e4698968c@news.min.net>,
John Porter <jdporter@min.net> wrote:
>Yep, that's what a moderated group is all about. No governments,
>large or otherwise, get involved. The perl community will
>moderate itself.
Really? I don't think so. I remember seeing a list of specific people
who would be the moderators for the moderated group. Or are you saying
that those people on the list are the "perl community"?
A "group moderating itself" is the definition of "unmoderated
newsgroup". "A select few moderating the rest" is how a moderated group
works.
------------------------------
Date: Fri, 01 May 1998 10:09:18 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: == vs. eq
Message-Id: <pudge-0105981009200001@ppp-5.ts-1.kin.idt.net>
In article <1d88l6t.1eln4fus1rfjkN@slip-32-100-246-240.ny.us.ibm.net>,
kpreid@ibm.net (Kevin Reid) wrote:
# Jason Gloudon <jgloudon@hyssop.bbn.com.bbn.com> wrote:
#
# > Greg Bacon <gbacon@cs.uah.edu> wrote:
# > >Greg
# > >--
# > >open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
# > >f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
# > >d2ac158c84c4ece4d22d1000118a8d5491000000
# > >EOF
# >
# > You should use Compress::Zlib. :).
#
# Greg,
#
# Please do. I would like to be able to run your signature under MacPerl.
Well, Compress::Zlib only partially works under MacPerl ... the zlib
library is borked in respect to dealing with filehandles or something on
Mac OS. I got the rest of it to work, though.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Fri, 01 May 1998 10:55:53 -0400
From: Brian Mathis <brianm@kodak.com>
To: Wiebe de Wolf <wiebe@worldcom.nl>
Subject: Re: Adding 600 users to a Linux password file
Message-Id: <3549E279.7D8BA4A0@kodak.com>
Wiebe de Wolf wrote:
>
> Hi there,
>
> I have to add 600 users (abo's) to a Linux password file. I have a list
> with the users and the passwords I like to use as a parameter.
>
> My idea was to use htpasswd in a perl script, but Perl is rather new to
> me
>
> exec "htpasswd /usr/local/conf/.valid_users NEW_USER";
>
[...]
You're probably better off crypting your own passwords, then dumping the
whole thing into a file. That way, you don't have to worry about the
resposes from htpasswd. (You can use the Expect.pm module to do it
though, if you want to). To generate the passwords all you need is a
function like this:
sub crypt_pass {
my($password) = @_;
my($salt, $len, $str);
$str =
'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890./';
$len = length($str);
srand( time^($$ + ($$<<15)) );
$salt = substr($str, rand($len), 1) . substr($str, rand($len), 1);
return crypt( $password, $salt );
}
To crypt the password, just: $crypted = crypt_pass($plaintext);
Now you don't have to deal with htpasswd..
Brian Mathis
orev
ps: if anyone can come up with a better way to define $str, let me
know..
------------------------------
Date: Fri, 01 May 1998 14:39:29 +0000
From: Stephen Hill <buck@huron.net>
Subject: alarm
Message-Id: <3549DEA1.4CF231B8@huron.net>
I want to call a subroutine, but have a time limit on the routine. If
the limit is hit, it exits the routine and continues with the rest of
the script. Below is my attempt to do it, but when the alarm reaches 5
seconds it exits the whole script, I want it to go back to the script
and keep working away.
& SubThingy;
print "It didn't kill the whole script, just the subroutine";
exit;
sub SubThingy{
alarm(5);
sleep 40;
print "hello world";
}
Any suggestions?
buck@huron.net
------------------------------
Date: Fri, 1 May 1998 11:04:15 -0400
From: "Les Woolsey" <lwoolsey@innovative.ca>
Subject: Any way to flush Perl output buffer
Message-Id: <6icoqm$ek3$1@nr1.ottawa.istar.net>
I have a Perl script that's making system calls in a loop. Just before the
call I put out a message to the console. But the message seems to be
buffered by Perl and don't appear before the output of the system call. Is
there some way (short of open & close of SYSOUT) to flush the Perl buffer?
Les
------------------------------
Date: Fri, 01 May 1998 11:07:52 -0400
From: Brian Mathis <brianm@kodak.com>
To: Les Woolsey <lwoolsey@innovative.ca>
Subject: Re: Any way to flush Perl output buffer
Message-Id: <3549E548.729C46AF@kodak.com>
Les Woolsey wrote:
>
> I have a Perl script that's making system calls in a loop. Just before the
> call I put out a message to the console. But the message seems to be
> buffered by Perl and don't appear before the output of the system call. Is
> there some way (short of open & close of SYSOUT) to flush the Perl buffer?
>
> Les
Yes.
$| = 1;
Take a look at the documentation in 'perlvar' (perldoc perlvar).
There's some other interesting variables in there.
Brian Mathis
orev
------------------------------
Date: Fri, 01 May 1998 15:17:00 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Any way to flush Perl output buffer
Message-Id: <MPG.fb3b2f990ce44d6989691@news.min.net>
On Fri, 1 May 1998 11:04:15 -0400,
in article <6icoqm$ek3$1@nr1.ottawa.istar.net>,
lwoolsey@innovative.ca (Les Woolsey) wrote:
> I have a Perl script that's making system calls in a loop. Just before the
> call I put out a message to the console. But the message seems to be
> buffered by Perl and don't appear before the output of the system call. Is
> there some way (short of open & close of SYSOUT) to flush the Perl buffer?
For shame; this is a FAQ: "How do I flush/unbuffer a filehandle?"
Also, look at the documentation for the open() operator.
John Porter
------------------------------
Date: 1 May 1998 15:18:41 GMT
From: culpep@bcm.tmc.edu (Pamela Culpepper)
Subject: Code works on Unix, and MacPerl. Why not Win32?
Message-Id: <6icp4h$prb@gazette.bcm.tmc.edu>
I am attempting to port Perl scripts that execute
correctly using Perl on Solaris2 and MacPerl on the
Mac to Win32 Perl.
The following sub works fine on Unix and the Mac,
but not on Win32.
print("Enter sequence file name (wildcard okay, return when done): ");
$_ = <STDIN>; &do_exit(0) unless $_; chop;
if ($_ eq '') {
last;
} elsif (/[\*\?\[\]{}~]/) {
@_ = &glob_files($_);
if (@_ == 0) {
print("No file names matched '$_'\n");
} else {
print("Matched: @_\n");
push(@ARGV, @_);
}
# Keep this at the end of the file, the globbing part throws off perl-mode
# in emacs.
sub glob_files
{
local($_) = @_;
local(@a);
@a = <${_}>;
grep(-f, @a);
}
Is is the file attribute?
Thanks,
Pam
--
Pamela A. Culpepper Senior Systems Analyst
Department of Molecular and Human Genetics
Baylor College of Medicine phone: 713/798-3733 fax: 713/798-5386
Houston, Texas 77030 culpep@bcm.tmc.edu
------------------------------
Date: Fri, 01 May 1998 14:18:50 GMT
From: jdporter@min.net (John Porter)
Subject: Re: comp.lang.perl.misc (was Re: Credit Card Verification scripts?)
Message-Id: <MPG.fb3a55d1f5518cf98968f@news.min.net>
On Fri, 01 May 1998 13:35:57 GMT,
in article <3550cf7f.11924656@news.tornado.be>,
bart.mediamind@tornado.be (Bart Lateur) wrote:
>
> For example, recently there was a thread on comp.lang.forth about
> whether programming "emotions" into the AI of robots would be
> benificial. This had absolutely nothing to do with the language, but
> only with a (hypothetical) programming task. Yet, nobody considered it
> off-topic.
Isn't this rather apples-and-oranges? How many newbies per day come
into clf asking yet again the same old FAQs? About 0, right?
That's not the situation we have here.
> The net result is that most of the posts are just syntax questions...
That's not the result, that's the cause.
> It looks like nobody wants to do any work.
Well that's pure b.s. And I personally take offense at the remark,
as I'm sure others do too.
> I think that by being more flexible in what gets allowed here, yes, even
> help-desk type posts, could, in the end, result in more interesting
> posts.
Maybe, by encouraging novices to the fullest extent possible, we'll have
a greater number of clueful discutants in the future. But the downside
is that if we do as you suggest, the signal-to-noise ratio will just
keep getting worse. It's already worse than it should be, and some of
us are trying to keep it in check.
John Porter
------------------------------
Date: Fri, 01 May 1998 10:34:24 -0400
From: Brian Mathis <brianm@kodak.com>
Subject: Re: comp.lang.perl.misc (was Re: Credit Card Verification scripts?)
Message-Id: <3549DD70.8BF3B45A@kodak.com>
Bart Lateur wrote:
> For example, recently there was a thread on comp.lang.forth about
> whether programming "emotions" into the AI of robots would be
> benificial. This had absolutely nothing to do with the language, but
> only with a (hypothetical) programming task. Yet, nobody considered it
> off-topic.
>
> I can't imagine something like this to happen on clpm.
I don't think that an actual constructive discussion about some theory
would be off topic. Techincally, yes, but I honestly don't see many
people complaining about something like this.
> On clpm, people are VERY picky about what is considered off-topic. The
> net result is that most of the posts are just syntax questions, but most
> of all: meta posts, and jests. (Even by me.)
I think it's the other way around. Most posts are syntax questions,
therefor, the net result are responses to that effect.
> It looks like nobody wants to do any work. All we seem to be doing, is
> fool around.
You got that right. All the guys that spent hours and hours putting
together some of the most complete documentation available on the net
did a very good job. Why should we put up with questions that are
easliy found in the documentation? This is a result of one programmer
not wanting to do simple work, so they ask here instead of trying to
find the answer. I wouldn't blame the people who are constantly saying
"read the documentation", I blame those who refuse to read it, and they
are the ones generating a mojority of the posts. I found it without
asking anyone, why can't they do the same?
> I think that by being more flexible in what gets allowed here, yes, even
> help-desk type posts, could, in the end, result in more interesting
> posts. Things we don't even think about now.
> Bart.
You can never convince me that posts like, "Why doesn't this work?" [50
lines of code], will ever be interesting. Most of the "help desk" type
questions have already been answered, somewhere on the user's own
machine.
I think that more interesting discussions would start if we didn't have
to wade through 200 posts a day asking "why won't my web page counter
work?"
Brian Mathis
orev
------------------------------
Date: 1 May 1998 14:53:26 GMT
From: lvirden@cas.org
Subject: Re: Credit Card Verification scripts?
Message-Id: <6icnl6$1af$1@srv38s4u.cas.org>
According to John Porter <jdporter@min.net>:
:And as we all know, what really matters here is what lvirden has seen
:enough of.
Nice quoting out of context. You are always such a ray of sunshine in
an otherwise dreary world of logic and reason.
--
<URL:mailto:lvirden@cas.org> Quote: In heaven, there is no panic,
<*> O- <URL:http://www.teraform.com/%7Elvirden/> only planning.
Unless explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
------------------------------
Date: Fri, 01 May 1998 11:01:57 -0400
From: Brian Mathis <brianm@kodak.com>
To: Rob Lowe <rob@imedianet.com>
Subject: Re: email attachments
Message-Id: <3549E3E5.51C191E6@kodak.com>
Rob Lowe wrote:
>
> how do I include an attachment to an email using the standard
> open(MAIL, "| /usr/sbin/sendmail -t");
> print MAIL ".."; etc.,
> format
That's is far from "standard". Yes, a ton of people are doing it, but
would you jump off a cliff... ?
You really should be using Net::SMTP to send your messages. It's much
safer.
For attaching a file, you should look at the MIME::* Modules. There's
probably something in there that will help you.
Brian Mathis
orev
------------------------------
Date: Fri, 01 May 1998 16:21:30 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: email attachments
Message-Id: <3549E87A.F1C5CDB7@nortel.co.uk>
Rob Lowe wrote:
> how do I include an attachment to an email using the standard
> open(MAIL, "| /usr/sbin/sendmail -t");
> print MAIL ".."; etc.,
> format
Again, visit my webpage under
http://www.surrey.ac.uk/~me51fq/perl/perl.htm
The first (and right now only) section is on how to produce an
attachment.
--
____________________________________________________________
Frank Quednau
Phone: +44 (0)1279 402447
http://www.surrey.ac.uk/~me51fq MailTo:F.L.Quednau@bnr.co.uk
____________________________________________________________
------------------------------
Date: Fri, 01 May 1998 14:34:21 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Evaluation of hex character representation in double quoted strings
Message-Id: <MPG.fb3a902f22e79b0989690@news.min.net>
On Fri, 1 May 1998 14:50:20 +0100,
in article <6icjpc$b78$1@news.u-net.com>,
gmorgan@photogrpahics.co.uk (Glenn Morgan) wrote:
>
> %entities = ('&', '\x26', '∧', '\xDEm1', '*', '*', .........)
>
> I then take a string, something like 'This & that', and look for
> anything that matches /(&[a-zA-Z\.]+\;)/ and use the value of $1 as a key to
> my hash %entities to return the corresponding characters to be inserted in
> the string in place of the lookup name. My problem is this, if the
> replacement character(s) contain a hexidecimal representation, when they are
> inserted into the string they are not evaluated as the corresponding
> character. So the string 'This & that' becomes 'This \x26 that' and not
> 'This & that' (assume you are using the same character mappings as me
> \x26=&). I know why this happening, cos the string has missed a double
> quoted evaluation, but I can't think of neat way to solve it (could be being
> stupid!)
The short answer is, use "\x26" in assigning your hash's values, rather
than '\x26'.
But maybe you want to consider a solution which has already been created
for you, namely HTML::Entities:
use HTML::Entities;
$s = "this & that\n";
print decode_entities( $s ); # prints "this & that".
hth,
John Porter
------------------------------
Date: Fri, 1 May 1998 16:08:33 +0100
From: "Glenn Morgan" <gmorgan@photogrpahics.co.uk>
Subject: Re: Evaluation of hex character representation in double quoted strings
Message-Id: <6icoei$d8v$1@news.u-net.com>
John Porter wrote in message ...
>On Fri, 1 May 1998 14:50:20 +0100,
>in article <6icjpc$b78$1@news.u-net.com>,
>gmorgan@photogrpahics.co.uk (Glenn Morgan) wrote:
>>
>> %entities = ('&', '\x26', '∧', '\xDEm1', '*', '*', .........)
>>
>> I then take a string, something like 'This & that', and look for
>> anything that matches /(&[a-zA-Z\.]+\;)/ and use the value of $1 as a key
to
>> my hash %entities to return the corresponding characters to be inserted
in
>> the string in place of the lookup name. My problem is this, if the
>> replacement character(s) contain a hexidecimal representation, when they
are
>> inserted into the string they are not evaluated as the corresponding
>> character. So the string 'This & that' becomes 'This \x26 that' and
not
>> 'This & that' (assume you are using the same character mappings as me
>> \x26=&). I know why this happening, cos the string has missed a double
>> quoted evaluation, but I can't think of neat way to solve it (could be
being
>> stupid!)
>
>The short answer is, use "\x26" in assigning your hash's values, rather
>than '\x26'.
>
>But maybe you want to consider a solution which has already been created
>for you, namely HTML::Entities:
>
>use HTML::Entities;
>$s = "this & that\n";
>print decode_entities( $s ); # prints "this & that".
>
>hth,
>John Porter
Thanks for your response. I am working with a proprietary SGML DTD and many
of the entities are non standard, therefore I suspect that HTML::Entities
will not suffice.
I think I was being a bit misleading when I used single quotes around the
hex character value. The ODBC module (as far as I know) always returns
strings and what appears to be happening is that by the time I receive the
string (prior to insertion into the hash) the string has the following value
'\x26' which is equal to '\' . 'x' .'2' . '6' (i.e. \x has no special
meaning in single or double quotes)
So what has happened is that \x has lost its special meaning and simply
become the characters
\ x
Ideally I want to force the reinterpretation of the string so that \x26 is
seen as the hex representation of a single character and not as a string
containing the four sequential characters \x26.
------------------------------
Date: Fri, 01 May 1998 15:40:44 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Evaluation of hex character representation in double quoted strings
Message-Id: <MPG.fb3b89181a6638f989692@news.min.net>
On Fri, 1 May 1998 16:08:33 +0100,
in article <6icoei$d8v$1@news.u-net.com>,
gmorgan@photogrpahics.co.uk (Glenn Morgan) wrote:
>
>...
> I think I was being a bit misleading when I used single quotes around the
> hex character value. The ODBC module (as far as I know) always returns
> strings and what appears to be happening is that by the time I receive the
> string (prior to insertion into the hash) the string has the following value
>
> '\x26' which is equal to '\' . 'x' .'2' . '6' (i.e. \x has no special
> meaning in single or double quotes)
>
>...
> Ideally I want to force the reinterpretation of the string so that \x26 is
> seen as the hex representation of a single character and not as a string
> containing the four sequential characters \x26.
One way is to use eval:
for ( keys %entities ) {
eval '$entities{$_} = "' . $entities{$_} . '"';
}
Here's another way:
for ( keys %entities ) {
if ( $entities{$_} =~ /^\\x(\d+)$/ ) {
$entities{$_} = chr(hex($1));
}
}
hth,
John Porter
------------------------------
Date: Fri, 01 May 1998 15:04:34 GMT
From: D.Parkin@icrf.icnet.uk (Dave Parkin)
Subject: fork problem
Message-Id: <3549e341.369211088@news.lif.icnet.uk>
I'm trying to write a program to do multiple simultaneous operations
in order to reduce the total time the program takes to run. I've got
the fork process working (thanks Tom), but am having real problems
retrieving the output of the children.
The program code is .....
#! /usr/local/bin/perl -w
use 5.004;
use strict;
use diagnostics;
use FileHandle;
my ($count, $pid, $read_a_line, @child_list, @handles, @results);
for ($count=1;$count<=3;$count++) {
$handles[$count-1]=FileHandle->new();
$pid=open($handles[$count-1],'-|');
if (not defined $pid) {
die "Couldn't fork: $?\n";
}
if ($pid) {
#Parent
push @child_list,$pid;
my $fh=$handles[$count-1];
while (<$fh>) {
push @results, $_;
}
} else {
#Child
my $timestamp;
sleep (10);
$timestamp=time();
print "timestamp: $timestamp\n";
exit(0);
}
}
$count=0;
foreach (@results) {
print ("$_\n");
}
The problem I'm having seems to be in the parent area where I try to
read the data from the filehandle. If I comment out the while loop, it
runs fine and the children are produced. If I have in the while loop,
the children are executed one after the other.
I've tried different approaches, but am stuck. Can anyone help,
please?
Dave
------------------------------
Date: Fri, 01 May 1998 15:58:51 +0100
From: Caroline Hadley <hadley@globin.bio.warwick.ac.uk>
Subject: need help with hashtable size/memory
Message-Id: <3549E32B.803D4B0A@globin.bio.warwick.ac.uk>
Hi all-
I'm creating 3 hashtables in my program, 2 of which have about 450,000
'keys' and associated values. The other one is smaller. I'm having huge
problems with the size of the program - most of the time it just crashes
after reaching about 120+Mb. I can't understand why it's getting this
big when the hashtables aren't that large.
I've asked a few other people about this, and I'm not the only one who's
seen this, but nobody had any decent ideas how to fix it. I can't use
'my' or 'local' (as I understand them) since I need the hashtables in a
subsequent routine. I'm trying to incorporate the Tie::SubstrHash
module, but so far haven't managed to get it to work. Is there any
alternative??
Here's part of the code that's causing all the problems:
#open file
while ($line = <FILE>)
{
$line =~ /(\S+)\s+((\d+\s+){2}\d+)/;
$string = $1;
$value = $2;
$hash{$string} = $value;
}
#close file
#each line of the file looks like this: frank_bobby 4 2 1
#i.e. an 11-character string followed by a series of numbers. There are
450,000+ sets of these.
I've only started using Perl in the past 6 months, so I'll be the first
to admit I don't have a clue. *ANY* help on this would be really
appreciated.
Thanks
Caroline
******************************************************************
Caroline Hadley
Bioinformatics/Protein Structure Group
Dept. of Biological Sciences
University of Warwick
Coventry CV4 7AL
England
E-mail: hadley@globin.bio.warwick.ac.uk
http://globin.bio.warwick.ac.uk/
Phone: +44 (0) 1203 572554
Supervisor: Dr. David T. Jones
******************************************************************
------------------------------
Date: Fri, 01 May 1998 15:54:07 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: Perl web server....
Message-Id: <3549e906.841231@news.tornado.be>
Chris Wertman wrote:
>Some time ago I saw a webserver written in perl.. I have searched .
>engines.DejaNews etc and stilll cannot find it ,... any pointers as to
>where on the web it may live are appreciated...
Could it just be that you're referring to HTTP::Daemon? Randal Schwartz
describes a project using it in one (err... two) of his most recent
WebTechniques. Look at column 23.
http://www.stonehenge.com/merlyn/WebTechniques/
HTH,
Bart.
------------------------------
Date: Fri, 01 May 1998 14:09:57 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Perl/Wall lingo question
Message-Id: <MPG.fb3a33b89e4db4198968d@news.min.net>
Keywords: OFFTOPIC VECTOR SCALAR
On Fri, 01 May 1998 13:36:20 GMT,
in article <3551cfc0.11989797@news.tornado.be>,
bart.mediamind@tornado.be (Bart Lateur) wrote:
> John Porter wrote:
>
> >A scalar is dimensionless, by definition.
>
> Nope. Zero dimensions is a point. A scalar, at least a numeric one, can
> be represented by a point (any point) on a line. Hence: one dimesion.
You magically transformed 0d into 1d.
Now think clearly.
A point is 0d. Being on a line, or on a plane, or in space, is
irrelevant. It's still a 0d point.
The point (:-) is this:
a vector represents a displacement from some origin, in some
number of dimensions. The magnitudes of the displacements in
each direction are clumped together into a homogeneous structure,
like an array. That's a vector. (x) is a one-dimensional vector
whose magnitude is x. How would one represent the magnitude of
a zero-dimensional vector? () would represent zero dimensions,
but there's no place for the magnitude. Thats why a 0d vector
is effectively no vector at all. And that's why we can say that
scalars are dimensionless.
John Porter
------------------------------
Date: Fri, 01 May 1998 15:39:40 +0100
From: Ian Boys <boys@aspentech.com>
Subject: Re: Perl/Wall lingo question
Message-Id: <3549DEAC.4287@aspentech.com>
brian d foy wrote:
>
> don't you mean *one* dimension? :)
>
Actually, no...I was busy writing a reply with one dimension, and then
I thought about it with furrowed brow, and then I changed my wording to
say zero dimensions.
The number of dimensions of a variable is is the number of subscripts
needed to reference a single value within it. The value of a scalar
is uniquely referenced without any subscripts, so it has zero
dimensions.
Since this argument holds whether the values stored are numbers,
strings or thingys, it can apply to Perl variables.
Consider:
x(P,Q,R) is an array with three dimensions
x(P,Q) is an array with two dimensions
x(P) is an array with one dimension
x is a scalar (with zero dimensions)
Terms and nomenclature used loosely to convey the idea - I am not a
mathematician.
Ian
------------------------------
Date: Fri, 01 May 1998 11:50:22 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl/Wall lingo question
Message-Id: <comdog-ya02408000R0105981150220001@news.panix.com>
Keywords: from just another new york perl hacker
In article <3549DEAC.4287@aspentech.com>, Ian Boys <boys@aspentech.com> posted:
>brian d foy wrote:
>>
>> don't you mean *one* dimension? :)
>The number of dimensions of a variable is is the number of subscripts
>needed to reference a single value within it. The value of a scalar
>is uniquely referenced without any subscripts, so it has zero
>dimensions.
> x(P) is an array with one dimension
> x is a scalar (with zero dimensions)
i thought about this last night in response to another post, and i think
the algebra of 1d vectors and scalars are equivalent. scalars can be
thought of as single component vectors. i was thinking specifically
about the integer versus complex (or any binomial) algebra. the integer
algebra can fit inside the rules of the complex algebra quite easily,
although you never end up with any cross terms, so you don't realize it.
furthermore, it hurts trying to think about something like simple
addition or subtraction on zero dimension objects, whose results should
have the same dimension :)
also, from my physics background, i tend to think of numbers as having
a dimension, such as mass, length, or so on (which is why i tend to
think we're arguing semantics). "dimension" means something different
to an algebrist and a physicist. we can argue all we want, but i think
it comes down to how we, as individuals, perceive the world since labels
and names tend to be arbitrary. some of us think a number represents a
point, hence the zero dimension camp, and others think it represents an
abstract difference, hence the one dimension camp.
in terms of Perl, all the other stuff doesn't matter. SCALARs have a
set of rules and the composite data types have other rules. whether
these fall into the classification of other fields (*heh*) matter as
long as they follow Perl's rules for whatever they are :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>
------------------------------
Date: Fri, 1 May 1998 17:32:59 +0400
From: "Abdul Nasar" <nasarma@emirates.net.ae>
Subject: Personal Web Server and Perl
Message-Id: <6icjsh$f2p@ws1.emirates.net.ae>
I have successfully installed Perl on my W95 PC . I wrote a cgi script on MS
Personal Web Server and a submit form(which calls this script) gives an
error
"HTTP 1.0 / 501 NOT SUPPORTED"
I have associated .pl files to execute perl.exe (as I got the information
from this news group few days back). If I double-click the above script it
is executed(it was intented to create a txt file)
I am new to perl and so can anybody tell me in detail
Nasar
------------------------------
Date: Fri, 01 May 1998 11:04:26 -0400
From: Brian Mathis <brianm@kodak.com>
To: Abdul Nasar <nasarma@emirates.net.ae>
Subject: Re: Personal Web Server and Perl
Message-Id: <3549E47A.4784714A@kodak.com>
Abdul Nasar wrote:
>
> I have successfully installed Perl on my W95 PC . I wrote a cgi script on MS
> Personal Web Server and a submit form(which calls this script) gives an
> error
> "HTTP 1.0 / 501 NOT SUPPORTED"
> I have associated .pl files to execute perl.exe (as I got the information
> from this news group few days back). If I double-click the above script it
> is executed(it was intented to create a txt file)
>
> I am new to perl and so can anybody tell me in detail
>
> Nasar
This is not a perl problem, but a problem with your web server set up.
I suggest looking up information about how to set up your web server to
deal with CGI. This topic has been discussed before, and you can
probably find some pretty good answers searching www.dejanews.com.
Brian Mathis
orev
------------------------------
Date: Fri, 01 May 1998 11:43:39 -0400
From: Eryq <eryq@zeegee.com>
To: rjk@coos.dartmouth.edu
Subject: Re: Ref to an LVALUE??? I expected a simple SCALAR ref!
Message-Id: <3549EDAB.6C8B05E@zeegee.com>
Ronald J Kimball wrote:
>
> Eryq wrote:
> >
> > What's going on? I've never seen a ref to an LVALUE before... where
> > do they come from, in this case?
>
> \substr($_, 1, 4) is a ref to an LVALUE. There are probably other expressions
> which return LVALUE refs. [1]
>
> I can't tell you more without seeing your more of your code.
Unfortunately, this is inside a *huge* Perl application; I
hit the problem when Storable:: raised an exception.
The data that hits the calling routine goes through many,
many different subroutines first.
I'm definitely not using substr() in that fashion... can
these things arise from misuse of @_ ? I gues my question is:
*** How might one [accidentally] obtain a ref-to-an-LVALUE?
To which answers begin with:
1. \substr(...)
2. ...
TIA,
--
___ _ _ _ _ ___ _ Eryq (eryq@zeegee.com)
/ _ \| '_| | | |/ _ ' / President, Zero G Inc: http://www.zeegee.com/
| __/| | | |_| | |_| |
\___||_| \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
|___/ |______/ of the homeless: http://www.streetwise.org
------------------------------
Date: Fri, 01 May 1998 15:55:03 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Ref to an LVALUE??? I expected a simple SCALAR ref!
Message-Id: <MPG.fb3bbe934722f1989693@news.min.net>
Looks to me like the debugger might come in handy here.
Set a breakpoint in the subroutine(s) which are throwing,
and then use the T command to get a call stack trace.
That way you can see what sub is calling what with a
LVALUE ref as an argument.
hth,
John Porter
------------------------------
Date: Fri, 1 May 1998 14:06:29 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Safest way to read from a socket?
Message-Id: <EsA76u.LBK@world.std.com>
Joel Horowitz <horowitz@ulb.ac.be> writes:
> I wondered if there's
>a simple way to read from a socket without knowing how much data (possibly
>none) is going to come from the data:
You can use the four argument version of select() to determine if a
socket is ready for reading, (or writing), use fcntl to make the
filehandle non-blocking, and use sysread() to get the data.
--
Andrew Langmead
------------------------------
Date: 1 May 1998 15:33:59 GMT
From: madf02@holyrood.ed.ac.uk (PGS Fluendy)
Subject: seg fault when matching long string
Message-Id: <6icq17$5mg@scotsman.ed.ac.uk>
When trying to perform the following:
$input =~ s/{\\fonttbl(.|\n)+;}}//;
on a string of about 13000 characters it works fine, but when on a
string of about 70000 I get a segmentation fault. Why?
Any help much appreciated.
Thanks,
Paul
--
------------------------------
Date: Fri, 01 May 1998 09:45:42 -0500
From: Andy Glew <glew@cs.wisc.edu>
Subject: Using executable pathname to define include path
Message-Id: <3549E016.FB3EF56B@cs.wisc.edu>
Can the following can be done in Perl:
discovery of the pathname of the executable, for use in defining module paths?
The perennial issue of software installations is "What is the path to the
libraries?" If you don't want to rely on user environment variables or
rc files, you typically hardwire them into an isolated submodule.
Another way, however, is to say "if you find the executable at
...path.../bin/executable, then the libraries are at ...path.../lib/...,
or some similar name convention. This has the advantage that
you can move the module around as a block, and if you type in
a full pathname to execute a program ...path.../bin/executable,
then it just works, with no other installation.
I have coded up varieties of this before, but, unfortunately, there
seems to be no foolproof way in UNIX to obtain the pathname of
the executable. The user can always lie, and make argv[0] a basename,
or, not even related to the program at all.
While you can try to look at the path to reverse engineer things, this
is not guaranteed to work.
Still, I would be happy with the argv[0]/path kluge, except that I have
not figured out how to get such code used at compile time, i.e. within
BEGIN
{
unshift(@INC,"...");
}
so that I can use the pathname of the perl program to define the
include path for the Perl modules it uses.
---
Please respond by email; I don't read this group.
------------------------------
Date: Fri, 01 May 1998 10:39:56 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: You people want Perl to be popular?
Message-Id: <pudge-0105981040090001@ppp-61.ts-1.kin.idt.net>
In article <6i844n$e68$1@marina.cinenet.net>, cberry@cinenet.net (Craig
Berry) wrote:
# I R A Aggie (fl_aggie@thepentagon.com) wrote:
# : In article <1d88t75.16la9373easowN@slip166-72-108-69.ny.us.ibm.net>,
# : kpreid@ibm.net (Kevin Reid) wrote:
# : + "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> wrote:
# : + > We want Perl to be useful. Popularity ain't all it's cracked up to be.
# :
# : + Being popular helps it be useful, because more people would be writing
# : + scripts, modules, etc...
# :
# : So, you're saying that Mac's aren't terribly useful and Wintels are
# : overwhelmingly userful? You do realize that is the implication, yes?
#
# Well, yes, actually. In a vacuum, viewed as isolated systems, a Mac may
# well be technically superior to a Wintel in several ways. However, the
# vastly higher number of Wintels deployed *does* make a Wintel more useful.
omigosh, are you high?
# If I generate a document, program, or the like on a Wintel box, I can
# easily share it with the vast majority of computer users; if I do so on a
# Mac, there's a conversion hurdle to be crossed before I can do that.
Not if you have a brain and decent tools. Conversion is usually a
non-factor these days between platforms, only between apps. I share Word
files weekly with PC users with absoutely no conversion required. Same
with Photoshop files and many others.
# If I
# need an app that does some job, the odds of my finding one are much higher
# for a Wintel box.
That's a fallacy. In specific cases, it may be much higher (for CAD, for
instance). But in the general case, it is false. There is no significant
difference.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
MacPerl: Power and Ease (ISBN 1881957322), http://www.ptf.com/macperl/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 2472
**************************************