[15696] in Perl-Users-Digest
Perl-Users Digest, Issue: 3109 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 21 00:06:03 2000
Date: Sat, 20 May 2000 21:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <958881908-v9-i3109@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 20 May 2000 Volume: 9 Number: 3109
Today's topics:
Re: ARGGH!HELP! Can't parse these characters ÿ þ <lr@hpl.hp.com>
Re: Bug or Feature: Can't dereference array ref inside (Dave Brown)
Re: comparing dates <lr@hpl.hp.com>
Comparing variables in a conditional "if" statement..PL <destiny30@telusplanet.net>
Re: file locking <godzilla@stomp.stomp.tokyo>
Re: file locking <The__Patrician@Hotmail.com>
Re: file locking <godzilla@stomp.stomp.tokyo>
Re: file locking <lr@hpl.hp.com>
Re: file locking <godzilla@stomp.stomp.tokyo>
Re: file locking samurai@metallicafan.com
Re: Forum for 'how to do it' questions? <anmcguire@ce.mediaone.net>
Re: Forum for 'how to do it' questions? <tony_curtis32@yahoo.com>
Re: Forum for 'how to do it' questions? (Randal L. Schwartz)
Re: interface with NetLedger XML interface (Todd Boyle)
Re: matching question(s) <lr@hpl.hp.com>
Re: matching question(s) <s0218327@unix1.cc.ysu.edu>
Re: Novice request for help to simplify matching <lr@hpl.hp.com>
Re: pc line breaks <lr@hpl.hp.com>
Re: perl for windows 95 <lr@hpl.hp.com>
Re: printing all variables! <sumengen@hotelspectra.com>
Q: Dynamic loading of modules. <thomas2@dalnet.se>
Re: Q: Dynamic loading of modules. <uri@sysarch.com>
regexes *sigh* damn I hate these things <nospam@devnull.com>
Re: regexes *sigh* damn I hate these things (Warren Jones)
Re: regexes *sigh* damn I hate these things <godzilla@stomp.stomp.tokyo>
Re: Resource Temporarily Unavailable <ppi@searchy.net>
Re: STDOUT (David Efflandt)
Re: Tanspose rows to columns <xah@xahlee.org>
Re: timeout a perl script? (David Efflandt)
Re: zen and the art of trolling [OT] <xah@xahlee.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 20 May 2000 16:08:44 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: ARGGH!HELP! Can't parse these characters ÿ þ
Message-Id: <MPG.1390bad14626bb8798aaa5@nntp.hpl.hp.com>
In article <190520001952261163%adsf@dsaf.com>, adsf@dsaf.com says...
> I'm trying to do this
>
> <snip>
> @prods=split(/ÿ/,$value);
> </snip>
>
> Where $value would be something like
>
> QtyþSKUþNameþNoTaxþPriceþTotalÿ1þ123þBig
> Widgetþ1þ$10.00þ$10.00ÿ1þ456þWidget 2þ0þ$5.00þ$5.00
>
> Then I was hoping to do
>
> <snip>
> foreach $morsel(@prods) {
> ($Q, $C, $D, $F,$P) = split(/þ/,$morsel);
> <snip>
>
> To get each tasty bit into a separate variable.
>
> The problem seems to be those nasty little characters... ÿ þ.
There should be no problem at all with them, except for pronouncing their
names. :-)
> I've looked everywhere for some solve but to no avail.
>
> Is this some special unicode trick?
I don't see any Unicode there.
> Please help. I'm desparate.
I don't know what your difficulty is. The following is copied and edited
from your post, and seems to work just fine.
#!/usr/local/bin/perl -w
use strict;
my $value = 'QtyþSKUþNameþNoTaxþPriceþTotalÿ1þ123þBig
Widgetþ1þ$10.00þ$10.00ÿ1þ456þWidget 2þ0þ$5.00þ$5.00';
my @prods = split /ÿ/ => $value;
foreach my $morsel (@prods) {
my @bits = split /þ/ => $morsel;
print "@bits\n\n";
}
Output:
Qty SKU Name NoTax Price Total
1 123 Big
Widget 1 $10.00 $10.00
1 456 Widget 2 0 $5.00 $5.00
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 20 May 2000 21:22:30 -0500
From: dhbrown@apm6-154.realtime.net (Dave Brown)
Subject: Re: Bug or Feature: Can't dereference array ref inside hash
Message-Id: <slrn8ie06t.sb.dhbrown@hobbes.edgerock.org>
In article <stevel-1905001548540001@192.168.100.2>, Steve Leibel wrote:
>I wasn't running with -w originally. My bad. In any event I'm now using
>square brackets for an array reference. I must say though that the
>distinction between lists and arrays is one of the more confusing features
>of Perl. For example if you look at all the documentation in the Camel
>book, etc., you find that all the examples of arrays of arrays are notated
>as LoL, ie "lists of lists." So even the authors are not rigorously clear
>about the distinction between () and []. And in cases where a syntactic
>distinction is subtle but important, good documentation should be crystal
>clear.
I hesitate to post an answer since I'm definitely not a guru, but a
recent entrant into the world of perl.
But the ( .. ) create an anonymous list (unless you assign to an array
variable name. The [ .. ] yield a reference to an anonymous list, i.e.,
a scalar. Hence when you ([..],[..],[..]), you've created an array of
references.
(PS, I think the "odd" number of somethings in the error message had
to do with the fact that an empty list () is like a null, so it
maybe thought that you shouldn't key to a null.)
--
Dave Brown Austin, TX
------------------------------
Date: Sat, 20 May 2000 16:44:31 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: comparing dates
Message-Id: <MPG.1390c3379dfebf2098aaa8@nntp.hpl.hp.com>
[This followup was posted to comp.lang.perl.misc and a copy was sent to
the cited author.]
In article <39270B11.F98A3D5@texas.net>, cure@texas.net says...
> how can i compare the dates
> example
> 31-12-99 is less than 1-1-2000
> 99 == 2000
I have asked you several times, but never received an answer. Why are
you peppering this newsgroup with questions that can be solved by reading
the documentation or by a minimal exertion of thought? If you are
getting paid to answer these questions for others, you ought to share
your pay with the rest of us.
perlfaq4:
How can I compare two dates and find the difference?
How can I take a string and turn it into epoch seconds?
Now is there any reason why you couldn't have found that for yourself?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sun, 21 May 2000 03:36:01 GMT
From: Pasquale <destiny30@telusplanet.net>
Subject: Comparing variables in a conditional "if" statement..PLEASE HELP!!
Message-Id: <39275AD5.DF472643@geocities.com>
Can anyone tell me what is wrong with this? How can I get the script to
check if the incoming address already exists in the log file? I've also
tried matching with regular expressions instead of comparing the
variables, but that doesn't work. The closest I've come to this working
is when I use the "= =" instead of the "eq". It will tell me the
address already exists if I try to add it again, but it will also tell
me it exists if I input an address with the same house number but
different street. Any suggestions would be GREATLY appreciated!!
open(ADR, "< adr.log");
flock(ADR, 2);
@adrs = <ADR>;
flock(ADR, 8);
close(ADR);
foreach $addr(@adrs) {
if ($address eq $addr) {
&existerr;
}
}
------------------------------
Date: Sat, 20 May 2000 16:20:29 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: file locking
Message-Id: <39271DBD.A659A924@stomp.stomp.tokyo>
Tad McClellan wrote:
> Godzilla! <godzilla@la.znet.com> wrote:
> >Cure wrote:
> >flock (FILE_HANDLE, 2)
> >flock (FILE_HANDLE, 8)
> >Both are old fashion strict methods of
> >locking and unlocking a file, respectfully.
> ^^^^^^^^^^^^
> If you don't talk nice to your filehandles they won't do what you ask?
Those of us well educated in Language and Linguistics
are aware "respectfully" within this context means,
"Reference to the order given previously."
In this case, the order given is lock and unlock,
respectfully denoting the order given in code
previously, lock and unlock.
Jill, Jackie and John are our corporate officers,
President, Vice-President and CEO, respectfully.
Always knew my doctorate in English would pay
off one of these here days.
*considers Mr. Xah's comments on linguistics and theory*
It's all intellectually relative Mr. Xah.
I find you to be a fascinating study in
human awareness and my personal notion of,
"Having a lick of sense."
Godzilla!
------------------------------
Date: Sun, 21 May 2000 02:26:49 +0200
From: Alexander Melchers <The__Patrician@Hotmail.com>
Subject: Re: file locking
Message-Id: <39272D48.9289F46F@Hotmail.com>
By using Fcntl as follows:
use Fcntl qw/:flock/;
You may import the constants (as LOCK_EX) which can be used with the
flock call...
Cure wrote:
> when I use the flock function can i use the params instead of the
> numbers whats the difference
> example flock(FH,2);
> flock(FH,LOCK_EX); whats the difference between the two
The difference is that one is a number, the other a constant. Why it's
best to use constants in most cases is that a constant can be made
global, so you may use it throughout your code, which means that to
change the value with which a sub is called, you'd only need to change
the constant. An obvious reason in this case would be that if on the OS
Perl's running on 2 wouldn't lock the file, LOCK_EX would, because it's
value is not hard coded in your code, but in the Fcntl library, which
might be different on your OS than on another OS... Thus using the
constants you make your code more portable...
>
>
> and does perl automatically unlock the filehandle for you
Yes it does...
> bye the way flock(FH,2) this locks the filehandle right?
------------------------------
Date: Sat, 20 May 2000 18:05:26 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: file locking
Message-Id: <39273656.1A1D8780@stomp.stomp.tokyo>
Alexander Melchers wrote:
> By using Fcntl as follows:
> use Fcntl qw/:flock/;
> You may import the constants (as LOCK_EX) which can be used with the
> flock call...
> Cure wrote:
> > when I use the flock function can i use the params instead of the
> > numbers whats the difference
> > example flock(FH,2);
> > flock(FH,LOCK_EX); whats the difference between the two
> The difference is that one is a number, the other a constant. Why it's
> best to use constants in most cases is that a constant can be made
> global, so you may use it throughout your code, which means that to
> change the value with which a sub is called, you'd only need to change
> the constant. An obvious reason in this case would be that if on the OS
> Perl's running on 2 wouldn't lock the file, LOCK_EX would, because it's
> value is not hard coded in your code, but in the Fcntl library, which
> might be different on your OS than on another OS... Thus using the
> constants you make your code more portable...
For trivia sake, the old fashion way of doing
this is to declare "Literals" which are actually
Globals under a different name:
$LOCK_SH = 1;
$LOCK_EX = 2;
$LOCK_NB = 4;
$LOCK_UN = 8;
$TRUE = 1;
$FALSE = 0;
A lock call would look like this:
flock (FILE_HANDLE, $LOCK_EX);
True and False, as such:
$var1 = $TRUE;
$var2 = $FALSE;
I believe these once popular grandmother methods
might be what led to names now used under Fcntl,
to greater advantage as you have discussed.
How many remember use of Literals in Perl?
Godzilla!
------------------------------
Date: Sat, 20 May 2000 18:29:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: file locking
Message-Id: <MPG.1390dbd1d7df224a98aaaa@nntp.hpl.hp.com>
In article <39271DBD.A659A924@stomp.stomp.tokyo>,
godzilla@stomp.stomp.tokyo says...
> Tad McClellan wrote:
> > Godzilla! <godzilla@la.znet.com> wrote:
> > >Cure wrote:
> > >flock (FILE_HANDLE, 2)
> > >flock (FILE_HANDLE, 8)
>
> > >Both are old fashion strict methods of
> > >locking and unlocking a file, respectfully.
>
> > ^^^^^^^^^^^^
>
> > If you don't talk nice to your filehandles they won't do what you ask?
>
> Those of us well educated in Language and Linguistics
> are aware "respectfully" within this context means,
>
> "Reference to the order given previously."
Which dictionary shows that definition?
> In this case, the order given is lock and unlock,
> respectfully denoting the order given in code
> previously, lock and unlock.
>
> Jill, Jackie and John are our corporate officers,
> President, Vice-President and CEO, respectfully.
<URL:http://www.m-w.com/>
Main Entry: re·spect·ful
Pronunciation: ri-'spekt-f&l
Function: adjective
Date: 1687
: marked by or showing respect or deference
- re·spect·ful·ly /-f&-lE/ adverb
- re·spect·ful·ness noun
Main Entry: re·spec·tive·ly
Function: adverb
Date: 1605
1 : in particular : SEPARATELY <could not recognize
the solutions as salty or sour, respectively>
2 : in the order given <Mary and Anne were
respectively 12 and 16 years old>
> Always knew my doctorate in English would pay
> off one of these here days.
You should give back your dictionary or your degree, or both. Is there
*no* field of endeavor in which you are competent?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 May 2000 19:44:44 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: file locking
Message-Id: <39274D9C.3D46B817@stomp.stomp.tokyo>
Larry Rosler wrote:
> You should give back your dictionary or your degree, or both. Is there
> *no* field of endeavor in which you are competent?
I am most competent in enticing people
to display their true colors, which are
often not pretty pastels of pink.
Rather embarrassing for people to
display how quickly they will jump
on a chance to be hateful for the
most petty of reasons, with the
beckoning no more than a wiggle
of a little finger or some silly
semantic trickery.
Fascinating how much power a person
holds when he or she has a healthy
ego, most fascinating.
Well, I am off to continuing filing
formal complaints against those of
you who tried a denial of service
style attack last night. Pretty
funny actually. Didn't work out
so good for you boys.
=)
Respectively,
Godzilla!
------------------------------
Date: Sat, 20 May 2000 20:38:26 -0700
From: samurai@metallicafan.com
Subject: Re: file locking
Message-Id: <39275A32.EA385840@metallicafan.com>
"Godzilla!" wrote:
> Rather embarrassing for people to display how quickly they will jump on a
> chance to be hateful
Tad McClellan wrote:
> If you don't talk nice to your filehandles they won't do what you ask?
This is hateful? Thin-skinned, thou art, King of the Tyrant Lizards.
> with the beckoning no more than a wiggle of a little finger or some silly
> semantic trickery.
Ahh yes. "Silly semantic trickery," like using words completely
incorrectly. But those of us not well edjamacated in "Language" and
"Linguistics" wouldn't understand that it's just "style," right? Where'd you
get your doctorate? Maybe I'll pick one up this week.
> Well, I am off to continuing filing formal complaints against those of you
> who tried a denial of service style attack last night.
Hmm. Pretty busy lately. Maybe you should consider a career in law.
> Pretty funny actually. Didn't work out so good for you boys.
"Boys?" I find that terribly sexist. If you don't cease and desist with
your misanthropist terminology, I'll have no recourse but to take legal
action upon thee, thy provider, thy computer maker, and everyone you've ever
had contact with, imagined or otherwise.
En taro adun,
///
------------------------------
Date: Sat, 20 May 2000 17:57:01 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <Pine.LNX.4.20.0005201746360.9382-100000@hawk.ce.mediaone.net>
On Fri, 19 May 2000, jones wrote:
+Simple question: are the comp.lang.perl.misc or alt.perl forums suitable
+for novice perl students to ask 'how do I do that' questions? I am stuck
+trying to do probably a simple task, and would like advice, but would
+like to use the appropriate forum. Thanks,
+
Well, I can't speak for alt.perl, I generally do not post or read
there. However, as far as comp.lang.perl.misc is concerned, I share
with you what I have observed...
The 'rules' for posting questions to comp.lang.perl.misc are something
like this:
1. Consult the documentation concerning what you are trying to
do.. perldoc is a good start. If for some reason you do not
have access to online documentation, you can find the FAQ in
HTML format at www.perl.com. Also there is www.perlfaq.com,
which allows you to search a database of FAQ's.
2. Do a search on Deja, see if your question has been asked before.
3. Check out a search engine, see if there is any other documentation
pertaining to what you are trying to do.
4. Check out any books you may have.
5. As your friends or co-workers if they know how to do what it
is you are trying to do.
6. If all the above fails, post a minimal working program,
that uses '-w' and 'strict' and demonstrates what you
are trying to do, along with a well worded explanation
of what you are trying to do.
HTH,
anm
--
/*-------------------------------------------------------.
| Andrew N. McGuire |
| anmcguire@ce.mediaone.net |
`-------------------------------------------------------*/
------------------------------
Date: 20 May 2000 18:01:23 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <87n1lkzv0c.fsf@limey.hpcc.uh.edu>
>> On Sat, 20 May 2000 17:57:01 -0500,
>> "Andrew N. McGuire " <anmcguire@ce.mediaone.net> said:
> Well, I can't speak for alt.perl, I generally do not
> post or read there.
I just had a look so you don't have to.
Don't bother. It's full of people SCREAMING IN UPPER
CASE. At least that was the impression I got. clpm is
quite a sane place in comparison :-)
hth
t
------------------------------
Date: 20 May 2000 16:57:37 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Forum for 'how to do it' questions?
Message-Id: <m1em6w4vwu.fsf@halfdome.holdit.com>
>>>>> "Tony" == Tony Curtis <tony_curtis32@yahoo.com> writes:
>> Well, I can't speak for alt.perl, I generally do not
>> post or read there.
Tony> I just had a look so you don't have to.
Tony> Don't bother. It's full of people SCREAMING IN UPPER
Tony> CASE. At least that was the impression I got. clpm is
Tony> quite a sane place in comparison :-)
There are fewer experts wandering through alt.perl, so it's often the
blind leading the blind. I hang out there just to see if I can stop
bad cargo cult viruses from spreading. I'm not very successful. :(
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Sun, 21 May 2000 03:40:10 GMT
From: tboyle@NoSMAProsehill.net (Todd Boyle)
Subject: Re: interface with NetLedger XML interface
Message-Id: <3929575c.260694046@192.168.0.166>
"LinkWorm Software, Inc." <webmaster@linkworm.com> wrote:
> why are you SPAMMING for them?
I was not spamming for them. I was informing the readers of the
group of the availability of a good, useful set of XML schemas for
exchange of business transactions.
Have you ever tried to find a usable set of XML schemas, for
integrating small business software? There aren't any. Here's what
this is all about: http://www.gldialtone.com/webledger.htm
(yet another freebie website representing about 5000 hours
of time I have donated to this purpose)
There are probably a few people who found smbXML useful. If not, they
undoubtedly found their downarrow or spacebar easier than you! :-)
>At least consider if your long post had anything to do with _Perl_
>before posting it!
><SNIP>
>
>Why is there so much SPAM from deja.com accounts lately? (I mean, more
>than usual?)
Hey, who are you anyway? What's LinkWorm? Is this your forum, here?
* Todd F. Boyle CPA http://www.GLDialtone.com/
* tboyle@rosehill.net Kirkland WA (425) 827-3107
* XML accounting, WebLedgers, ASPs, GL dialtone, whatever it takes
------------------------------
Date: Sat, 20 May 2000 15:06:48 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: matching question(s)
Message-Id: <MPG.1390ac55ceca5a5298aaa3@nntp.hpl.hp.com>
In article <Pine.A41.4.20.0005192353280.48328-100000@unix1.cc.ysu.edu>,
s0218327@unix1.cc.ysu.edu says...
> On Fri, 19 May 2000, Larry Rosler wrote:
> > > $_="@all_keys";
> > > @valid_keys=grep(!/\b$badkey\b/,m/\b[a-z]{$len}\b/g);
> >
> > @valid_keys = grep !/\b$badkey\b/ => /\b[a-z]{$len}\b/g;
> >
> > @valid_keys = grep !/\b$badkey\b/ =>
> > map /\b[a-z]{$len}\b/g => @all_keys;
> >
> > @valid_keys = grep $_ ne $badkey =>
> > map /\b[a-z]{$len}\b/g => @all_keys;
>
> thank's for answering my earlier question; appreciated it.
> i tried your solutions with the same input data; and got the
> same output from all of them. however, here's the comparison
> of them in CPU seconds (using Benchmark):
>
> 1st - 48.93 (my original version)
> 2nd - 49.39
The second statement parses to the same code as the first, so this
difference is just noise.
> 3rd - 211.15
> 4th - 185.00
So apparently the equality test is somewhat faster than the regex match,
as I expected.
> then i modified it to:
>
> $_="@all_keys";
> @valid_keys=grep $_ ne $badkey => /\b[a-z]{$len}\b/g;
>
> and turned out to be the fastest: 46.81
> still though, could i do better? =)
I was quite surprised by your numbers, which seem to show almost a four-
to-one speed advantage to stringifying an array before applying a regex
compared to mapping the regex over each element in the array. So I put
together my own benchmark, and these are the results:
Benchmark: timing 1024 iterations of Map, Step1, Step2, String...
Map: 5 wallclock secs ( 4.50 usr + 0.00 sys = 4.50 CPU)
Step1: 0 wallclock secs ( 0.16 usr + 0.00 sys = 0.16 CPU)
(warning: too few iterations for a reliable count)
Step2: 4 wallclock secs ( 4.34 usr + 0.00 sys = 4.34 CPU)
String: 5 wallclock secs ( 4.51 usr + 0.00 sys = 4.51 CPU)
Here Step1 is the stringification and Step2 is the regex match. There is
no measurable difference between these two approaches.
The data are a 100-element array of randomly-lengthed words, where we are
picking out five-letter words. I post the code below, so you or others
can experiment. It might be instructive for you to post the code that
gave the large difference that you reported.
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
use vars qw( @a $s );
@a = map join(" " => map 'x' x (1 + rand 9) => 0 .. 9), 0 .. 99;
$s = "@a";
timethese(1 << (shift || 0), {
Map => 'my @b = map /\b\w{5}\b/g => @a',
Step1 => 'my $x = "@a"',
Step2 => 'my @b = $s =~ /\b\w{5}\b/g',
String => 'my @b = "@a" =~ /\b\w{5}\b/g',
});
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 May 2000 22:00:36 -0400
From: NagaPutih <s0218327@unix1.cc.ysu.edu>
Subject: Re: matching question(s)
Message-Id: <Pine.A41.4.20.0005202120410.51058-100000@unix1.cc.ysu.edu>
here's the code i mentioned in previous postings:
sub mysub {
my($len,$adj,@allwords)=@_;
my(@adjacent_vertices,@selected_words,$word,$re,$idx);
$_="@allwords"; @words=m/\b[a-z]{$len}\b/g;
foreach $word (@selected_words) {
for($idx=0;$idx<$len;$idx++) {
$re=substr($word,0,$idx)."[a-z]".substr($word,$idx+1);
# before modification
# $_="@words"; @adjacent_vertices=grep(!/\b$word\b/,m/\b$re\b/g);
# after modification
$_="@words"; @adjacent_vertices=grep $_ ne $word => /\b$re\b/g;
push(@{$adj->{$word}},@adjacent_vertices);
}
}
}
the numbers i gave you were obtained from benchmarking result
on a 486dx66, with an array of 110298 words of different lengths.
thank's again.
------------------------------
Date: Sat, 20 May 2000 15:54:37 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Novice request for help to simplify matching
Message-Id: <MPG.1390b78272e88faf98aaa4@nntp.hpl.hp.com>
In article <3925C83F.3F5E5C55@wsb.com>, jhelman@wsb.com says...
> Oops. Point taken. Can you tell that my brain has pretty much stopped
> functioning for the night. :) To be correct, the "if
> ($ENV{'REMOTE_ADDR'..." line should read:
>
> if ($ENV{'REMOTE_ADDR'} =~ /^\Q$ipx[$i]\E/) {
>
> or, in the case of my second post:
>
> if ($ENV{'REMOTE_ADDR'} =~ /^\Q$addr\E/) {
>
> Good catch. Thanks.
A better catch would be to ask why you are using those dolled-up regex
matches instead of simple string equality testing. Do you really want
1.2.3.40 to match 1.2.3.4? So you could append '$' to those regexes, but
don't!
As a general principle, any regex that reads /^\Qwhatever\E$/ is better
replaced by a string comparison or an index test. (If the /i modifier
would be needed, use lc() on one or both operands.)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 May 2000 16:16:18 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: pc line breaks
Message-Id: <MPG.1390bc9f6c7207ad98aaa6@nntp.hpl.hp.com>
In article <8g5upp$ifr$2@slb7.atl.mindspring.net>, ebohlman@netcom.com
says...
> David Efflandt (efflandt@xnet.com) wrote:
> : On Sat, 20 May 2000, Markus Svilans <bh447@freenet.carleton.ca> wrote:
> : >
> : >Does anyone know the regular expression to match PC line breaks? I'm
> : >reading data in from a file that has PC linebreaks, and due to
> : >circumstances it is not possible to convert the file to Unix format.
> :
> : Line breaks in DOS/Win text files are \r\n
>
> It's really best to write that as \015\012 instead, as that will represent
> a CRLF sequence on any platform, whereas the actual value of \n varies
> from platform to platform; the values just happen to be correct on Unix,
> but would be wrong on a Mac or on a Win32 system reading a file in binary
> mode.
Why would the values be wrong 'on a Win32 system reading a file in binary
mode'? CR = "\r" = "\015", LF = "\n" = "\012", just as on Unix, no
matter what mode the file is being read in. If it is being read in text
mode, the sequence "\r" "\n" in the input stream is converted to "\n" by
the I/O subsystem.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 May 2000 16:33:06 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: perl for windows 95
Message-Id: <MPG.1390c083a56ea2d98aaa7@nntp.hpl.hp.com>
In article <3926B094.B79897C6@vpservices.com>, jeff@vpservices.com
says...
...
> You write the Perl program in any text editor or word processor that can
> save text as a plain ascii file. I use emacs but notepad will work
> too. Once you have written the program, open a DOS command shell and
> type in "perl filename" where filename is the name of the text file you
> saved your program in. ...
There is a Step 0 to confirm that the 'perl' command is in your PATH and
is functioning properly. At a command prompt, type:
perl -v
Assuming that works, go ahead with your programming, as described above.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 20 May 2000 16:35:14 -0700
From: "Baris" <sumengen@hotelspectra.com>
Subject: Re: printing all variables!
Message-Id: <3927220e_4@goliath.newsfeeds.com>
Hello,
it is a cgi program (not written by me). Is it possible to apply a similar
strategy to it?
Baris.
"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3926DCEB.DDC471D4@rochester.rr.com...
> Baris wrote:
> >
> > Hello,
> > Can I print out all the global variables (or all variables) inside my
perl
> > program at some point? Or can I get that info somehow?
> > Baris.
> ...
> One way is: Run perl with the -d switch to run the debugger. Step or
> otherwise get to the appropriate point in the program, and issue the V
> command to the debugger.
> --
> Bob Walton
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Sat, 20 May 2000 22:19:35 GMT
From: "Thomas Åhlen" <thomas2@dalnet.se>
Subject: Q: Dynamic loading of modules.
Message-Id: <XbEV4.45$VF1.14738@dummy.bahnhof.se>
Hi!
In my code I load and eval modules when they are needed.
If same module is needed twice i don't want to reload it.
How do i check which modules that are loaded(used).
Code example:
------------------------------------------>
$module = "File";
$subroutine = "open";
$params = "test.txt";
$filename = "modules/" . $module . ".pm";
*cmd = $module . "::" . $subroutine;
# HOW do i CHECK if module File ALREADY has been LOADED??
if( $module not loaded ) {
open( FILE, $filename) or warn "Couldn't open module $module: $!\n";
@{$data} = <FILE>;
close( FILE );
$code = "@{$data}";
eval $code;
}
cmd($params);
<-------------------------------------------
Thomas Å
------------------------------
Date: Sat, 20 May 2000 22:39:57 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: Dynamic loading of modules.
Message-Id: <x73dncg81v.fsf@home.sysarch.com>
require
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: 21 May 2000 01:57:34 GMT
From: The WebDragon <nospam@devnull.com>
Subject: regexes *sigh* damn I hate these things
Message-Id: <8g7fqe$j48$0@216.155.32.125>
ok, I need help creating a regex to extract a number from a bit of html
here's a snip of the html
<p>Name: <a href="http://www.planetunreal.com/dl/nc.asp?nalicity/
utdm/dm-distinctive.zip">DM-Distinctive</a><br>
Author:<a href="mailto:bastiaan_frank@hotmail.com">Bastiaan Frank</a><br>
Rating: (1-10) 9.5</p><!-- add correct image name below here -->
<img align="right" border="0" hspace="10" vspace="10" width="231" height="173"
src="dm-distinctive.jpg">
I need to extract the number AFTER the Rating: (1-10) and before the </p>, which
can be any number from 0 to 10 in .5 increments
there may be a 0, or an 8.5 or a 10 or a 5 or a 5.5 etc.
I need ONLY that number.
Anyone up to the task?
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 20 May 2000 19:16:23 -0700
From: wjones@tc.fluke.com (Warren Jones)
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <8g7gtn$1pl$1@wauna.tc.fluke.com>
The WebDragon <nospam@devnull.com> writes:
> ok, I need help creating a regex to extract a number from a bit of html
>
> here's a snip of the html
>
> <p>Name: <a href="http://www.planetunreal.com/dl/nc.asp?nalicity/
> utdm/dm-distinctive.zip">DM-Distinctive</a><br>
> Author:<a href="mailto:bastiaan_frank@hotmail.com">Bastiaan Frank</a><br>
> Rating: (1-10) 9.5</p><!-- add correct image name below here -->
> <img align="right" border="0" hspace="10" vspace="10" width="231" height="173"
> src="dm-distinctive.jpg">
>
> I need to extract the number AFTER the Rating: (1-10) and before the </p>, which
> can be any number from 0 to 10 in .5 increments
>
> there may be a 0, or an 8.5 or a 10 or a 5 or a 5.5 etc.
>
> I need ONLY that number.
Don't hate regular expressions.
Regular expressions are your friend.
print "$1\n" if /Rating: \(1-10\)\s+(1?\d(\.[05])?)\s*<\/p>/;
Hmmm ... this will accept 10.5, but it won't accept .5 (no leading 0).
If that's a problem, hope this still gives you enough of a hint
at how to complete the solution.
--------------------------------------------------------------------
Warren Jones | To keep every cog and wheel is the first
Fluke Corporation | precaution of intelligent tinkering.
Everett, Washington, USA | -- Aldo Leopold
------------------------------
Date: Sat, 20 May 2000 20:32:54 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regexes *sigh* damn I hate these things
Message-Id: <392758E6.577C8C74@stomp.stomp.tokyo>
The WebDragon wrote:
> ok, I need help creating a regex to extract a
> number from a bit of html
> <p>Name: <a href="http://www.planetunreal.com/dl/nc.asp?nalicity/
> utdm/dm-distinctive.zip">DM-Distinctive</a><br>
> Author:<a href="mailto:bastiaan_frank@hotmail.com">Bastiaan
> Frank</a><br> Rating: (1-10) 9.5</p><!-- add correct image
> name below here --> <img align="right" border="0" hspace="10"
> vspace="10" width="231" height="173" src="dm-distinctive.jpg">
> I need to extract the number AFTER the Rating: (1-10) and
> before the </p>, which can be any number from 0 to 10
> in .5 increments there may be a 0, or an 8.5 or a 10
> or a 5 or a 5.5 etc.
> I need ONLY that number.
> Anyone up to the task?
Why bother with a possibly error prone
fancy regex when you can jump right in,
grab your number, jump out, and move on
with your program?
Try this and see if this simple little
old fashion whatever doesn't grab your
number of interest each and everytime,
with no fancy footwork.
Godzilla!
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$input = "
<p>Name: <a href=\"http://www.planetunreal.com/dl/nc.asp?nalicity/
utdm/dm-distinctive.zip\">DM-Distinctive</a><br>
Author:<a href=\"mailto:bastiaan_frank\@hotmail.com\">Bastiaan
Frank</a><br>
Rating: (1-10) 9.5</p><!-- add correct image name below here -->
<img align=\"right\" border=\"0\" hspace=\"10\" vspace=\"10\"
width=\"231\" height=\"173\"
src=\"dm-distinctive.jpg\">";
if ($input =~ / ([0-9\.]+)/)
{ $input = $1; }
print $input;
exit;
------------------------------
Date: Sun, 21 May 2000 03:28:23 +0200
From: Penpal International <ppi@searchy.net>
Subject: Re: Resource Temporarily Unavailable
Message-Id: <39273BB7.3DB3F71@searchy.net>
Probably the mysqlserver is down... To find out you could run a
MySQL-client on your PC and try to connect.
Maybe you could also try PHP for connecting to a MySQL database.
(http://www.php.net) It's easier (for mysql-stuf) to do.
Gabe wrote:
>
> My program is dying after trying to connect. $! gives Resource Temporarily
> Unavailable. Can anyone see why it's dying with that error?
>
> my $driver = "mysql";
> my $database = "cremeco_com";
> my $dsn = "DBI:$driver:database=$database";
>
> my $dbh = DBI->connect($dsn, $user, $password) || die &error;
>
> Gabe
--
Penpal International
http://ppi.searchy.net/
ppi@searchy.net
------------------------------
Date: 20 May 2000 23:20:21 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: STDOUT
Message-Id: <slrn8ie7d6.m66.efflandt@efflandt.xnet.com>
On 20 May 2000 21:17:20 GMT, Rob Zwartjes <rzwartje@robz.HOSTNAME> wrote:
>Hello perlers,
>
>I have a problem mixing printing to screen and printer. The following program
>is a example of what I want.
>
>#! /usr/bin/perl -w
>
>sub print1 {
> open (STDOUT,"| lpr") or die "Can't teeing: $!";
> for ($Counter=0; $Counter < 9 ; $Counter++) {
> print "hello\n";
> }
> close STDOUT;
>}
>
>sub print2 {
> open (STDOUT,"| lpr") or die "Can't teeing: $!";
> for ($Counter=0; $Counter < 9 ; $Counter++) {
> print "hello\n";
> }
> close STDOUT;
>}
>
>print "First print\n";
>&print1;
>sleep(20); # delaying the next print doesn't work
>print "Second print\n";
>&print2;
>
>The error I get is :
> print on closed filehandle main::STDOUT at ./printing 22
>I think that everything is going to fast, so I put a sleep in it. But that
>doesn't work. How can I overcome this problem on printing to a closed
>filehandle
You should use a different filehandle other than STDOUT for printing. The
problem is &print1 closes STDOUT without reopening it to the screen. So
if STDOUT is closed, where is the 'print "Second print\n";' supposd to
print to?
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 20 May 2000 15:58:05 -0700
From: Xah <xah@xahlee.org>
Subject: Re: Tanspose rows to columns
Message-Id: <B54C668D.A0CA%xah@xahlee.org>
merlyn@stonehenge.com (Randal L. Schwartz) quoted:
> The difference between theory and practice in theory is much less
> than the difference between theory and practice in practice.
Popular quotes have attributes of equivocal interpretation and theatrical
display. When interpreted and pondered by the wise, it lights up a wisdom,
but dullards quote them equally, and delight in their drama. (the latter
happens a lot in Perl and unix communities.)
From American Heritage Dictionary:
theory n. pl. theories 1. a. Systematically organized knowledge applicable
in a relatively wide variety of circumstances, especially a system of
assumptions, accepted principles, and rules of procedure devised to analyze,
predict, or otherwise explain the nature or behavior of a specified set of
phenomena. b. Such knowledge or such a system. 2. Abstract reasoning;
speculation. 3. A belief that guides action or assists comprehension or
judgment: rose early, on the theory that morning efforts are best; the
modern architectural theory that less is more. 4. An assumption based on
limited information or knowledge; a conjecture.
The word 'theory', in practice, has more meanings than in theory.
For example, in the above usage, 'theory' is used twice. In the first
instance, it is used for a purpose but not for its meaning. It is part of a
construction in a language that discuss the language itself. In theory it
does not come up, but in practice it does all the time. In practice, we can
say that the first instance of usage of the word 'theory' has no meaning
given the context. In the second appearance of the word, it has myriad of
interpretations due to the construction of the phrase.
People may mean: "The word 'theory', in practice, has more meanings than
people would think." Here the word is thus used conveniently to stand for
"mob's knowledge".
From a logical linguist's mouth, the intent might be: "The word 'theory',
outside academia, acquire more meanings and purposes than we require in
linguistics." The sensibility of such semantic content is demonstrated in
the previous paragraph.
People may say: "in theory, tomorrow'll rain." They really mean "the
broadcast station lady said that tomorrow will rain."
A detective might say, "in theory, that guy is the murderer.". He really
means: "according to my investigations, it is highly probably that that guy
is the murderer.". (dictionary definition #4.)
In a strict sense, 'theory' means systematic and organized principles
derived by scientific means (dictionary definition #1.). In a more strict
mathematical sense, 'theory' is the body of theorems, and theorem by
definition describes practices correctly always, else it is not a theorem.
It is possible for a mathematical theorem to be incorrect (we are humans,
after all), but in practice to assume that theorems can be incorrect is like
assuming one might be hit by a meteor tomorrow. Theoretically correct, but
not sensible.
As you can see, the word 'theory' is subject to wanton abuses. In fact, all
English words are subject to extraneous purposes to yield sentences or
paragraphs that has a meaningful ambiguous interpretation. (this is how
poetry works, in theory.) All in all, English is extremely malleable and
ambiguous. The phrase "The word 'theory', in practice, has more meanings
than in theory" is really silly, except in really well-defined context. In
our context, the quote amounts to illustrating the stupidity of Perlers who
don't have a solid background in logic or linguistics, but like to quote
about differences of theory vs. practice.
Larry Wall likes to mention how he had a linguistics background, and how he
utilized the (good) human qualities of English to create Perl. To the Perl
folks of beady eyes, they are sold a grand advance in computer science, but
to discerning eyes, it's artful garbage.
Sorry i don't have time to address the above points of Wall's, but this will
definitely be another lesson for you folks down the road.
The perl folks with their beads of little eyes, cannot see beyond imperative
languages.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: 20 May 2000 23:35:24 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: timeout a perl script?
Message-Id: <slrn8ie89d.m66.efflandt@efflandt.xnet.com>
On Sat, 20 May 2000, Dave Brondsema <qbasicguy@unitedstates.com> wrote:
>How could I make a perl script timeout after a while (like an infinite
>loop)?
>
>I've tried the alarm function, but that was unsupported. Is this something
>that I perl can do, or do I need to do it on the server? The server is
>running NT with Active Perl 5.
$timeout = 30; # seconds
$timeout += $^T; # add start time of script
while (1) {
# do something useful in endless loop
last if time > $timeout;
}
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Sat, 20 May 2000 15:59:20 -0700
From: Xah <xah@xahlee.org>
Subject: Re: zen and the art of trolling [OT]
Message-Id: <B54C66D8.A0CB%xah@xahlee.org>
perl_phreak@yahoo.com (Gordon Clemmons) wrote:
> You're an amusing little idiot. Thanks for the laughs (at, not with).
You're an unamusing little idiot. Thanks for the contrast.
Xah
xah@xahlee.org
http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3109
**************************************