[22421] in Perl-Users-Digest
Perl-Users Digest, Issue: 4642 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 28 11:11:09 2003
Date: Fri, 28 Feb 2003 08:10: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 Fri, 28 Feb 2003 Volume: 10 Number: 4642
Today's topics:
Re: require subs and global parameters (kydongau)
Re: require subs and global parameters (Anno Siegel)
Re: search algorithm needed <peakpeek@purethought.com>
sleep happening at the wrong time. <res1uzbe@verizon.net>
Re: sleep happening at the wrong time. (Anno Siegel)
Re: sleep happening at the wrong time. <tassilo.parseval@post.rwth-aachen.de>
Re: sleep happening at the wrong time. <res1uzbe@verizon.net>
Re: sleep happening at the wrong time. <tassilo.parseval@post.rwth-aachen.de>
Re: sleep happening at the wrong time. <ubl@schaffhausen.de>
Using AuthTicket with a Mac? (Pete Keiper-White)
Re: Using AuthTicket with a Mac? (Helgi Briem)
Re: Using AuthTicket with a Mac? <jurgenex@hotmail.com>
Re: Using AuthTicket with a Mac? (Tony L. Svanstrom)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Feb 2003 04:57:03 -0800
From: kydongau@yahoo.com.au (kydongau)
Subject: Re: require subs and global parameters
Message-Id: <738c2d89.0302280457.4e98da81@posting.google.com>
kydongau@yahoo.com.au (kydongau) wrote in message news:<738c2d89.0302251455.67b87d4c@posting.google.com>...
> Hi,
>
> Is it possible to require a perl file that contains sub routines as
> such:
>
> #main script
>
> my ($cmd);
>
> while .... {
> if bla {
> require "lib1.pl";
> } elsif blaaa {
> require "lib2.pl";
> }
> }
>
> where lib1 and lib2.pl contains the same sub NAME but doing different
> things and having access to the global variables $cmd from the main
> script ??
>
> If the if block is inside a while loop, can the sub NAME be replaced?
>
> My script failed when it tries to use $cmd.
>
> Thanks,
> Ky
I have another problem when lib1 and lib2 contain more than 1 subs,
say sub Name1, sub Name2, sub Name3 etc. Both lib files would the
same number of subs. If the if conditions are all bla or the other
then it is ok. But if the condition are a mix of bla and blaaa then
things are not quite right, subroutine redefined warning start popping
up and subs are not get replaced properly.
I think I can use dispatch tables to get around but I do not know how
to load these lib files into the dispatch tables and refer the subs in
the hash. Please show me if this is possible. Ofcourse I can make
all the subs having different names but that would be messy and maybe
it is my last option.
My other question is, if the conditions are all bla, then I dont get
the subroutine redefined message. Does it mean perl does not execute
the "require lib1.pl" statement if all the subs are the same from last
time?? ie, if there are three while irterations and they all meet if
bla condition, then require lib1 only get invoke on the first
irteration, am I correct ??
------------------------------
Date: 28 Feb 2003 13:19:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: require subs and global parameters
Message-Id: <b3nnle$nq9$4@mamenchi.zrz.TU-Berlin.DE>
kydongau <kydongau@yahoo.com.au> wrote in comp.lang.perl.misc:
> kydongau@yahoo.com.au (kydongau) wrote in message
> news:<738c2d89.0302251455.67b87d4c@posting.google.com>...
> > Hi,
> >
> > Is it possible to require a perl file that contains sub routines as
> > such:
> >
> > #main script
> >
> > my ($cmd);
> >
> > while .... {
> > if bla {
> > require "lib1.pl";
> > } elsif blaaa {
> > require "lib2.pl";
> > }
> > }
> >
> > where lib1 and lib2.pl contains the same sub NAME but doing different
> > things and having access to the global variables $cmd from the main
> > script ??
> >
> > If the if block is inside a while loop, can the sub NAME be replaced?
> >
> > My script failed when it tries to use $cmd.
> >
> > Thanks,
> > Ky
>
> I have another problem when lib1 and lib2 contain more than 1 subs,
> say sub Name1, sub Name2, sub Name3 etc. Both lib files would the
> same number of subs. If the if conditions are all bla or the other
> then it is ok. But if the condition are a mix of bla and blaaa then
> things are not quite right, subroutine redefined warning start popping
> up and subs are not get replaced properly.
They are replaced, it's only a warning. You can suppress the
warning (no warnings 'redefine'), or put "BEGIN { undef &xxx }"
before each sub declaration that may redefine an earlier one.
Anno
------------------------------
Date: Fri, 28 Feb 2003 11:47:49 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: search algorithm needed
Message-Id: <52hu5vsirnr5op774cnil7dkkj4lepe8cp@4ax.com>
On 27 Feb 2003 23:39:41 -0800, in comp.lang.perl.misc, massion@gmx.de (FMAS) wrote:
>I have written a script to select examples for terms in an array of
>phrases. This is to build up a dictionary and give context information
>for the use of the terms
> $limit = 0;
>foreach $term (@term) {
> for($phrasecounter=0 ; $phrasecounter <= $#phrase ; $phrasecounter++)
>{
> $phrase = $phrase[$phrasecounter];
> chomp $term;
> chomp $phrase;
>if ($phrase =~ m/(.*)(\b$term\b)(.*)$/gi)
>{
>if ($phrase ne $phrase[$phrasecounter++]) {
> if ($limit < 2){ # here I can define how many examples I select for
>one term
> print "$term\t$phrase\n\n";
> $limit++;
>}
>}
>}
>}
> $limit = 0;
>}
>The script works fine with the exception that it gets extremly slow
>when I have a large amount of terms and phrases. E.g. I have
>collections of terms of up to 5,000 and of phrases of up to 20,000.
>Currently it takes more than the complete night to do that job!
You are using a nested loop
5,000 * 20,000 = all night
>Does anyone have a suggestion as to how I could shorten the search
>time substantially?
Restructure your data into two sorted lists of words. Write a
single-loop algorithm which synchronously processes both lists
- merge and match
Build a data structure where the items in the word lists point
at the terms and phrases from which they were derived
The number of items will be much greater than 25,000 - maybe
200,000, depending on the total number of words in your terms
and phrases. But a single-loop algorithm will iterate only
once per item, ie ~200,000 iterations instead of 100,000,000
You still need to use your regexp match if there are any
multi-word terms
Re-sort the matches (after completing the main loop) to limit
the number of example phrases for each term, and to remove
duplicates
build data structures keyed by words
--> sort by word
--> merge and match
--> sort by term
--> apply limits and remove duplicates
--
Sharon
------------------------------
Date: Fri, 28 Feb 2003 13:05:23 GMT
From: emcee <res1uzbe@verizon.net>
Subject: sleep happening at the wrong time.
Message-Id: <n8J7a.16867$ES3.9509@nwrddc04.gnilink.net>
I posted this on comp.lang.perl, before I read a bit and relized its not
used much anymore:
It would seem to me that a code such as the following:
print $i++ while $i<5;
sleep 5;
Should print 01234, sleep 5 seconds and exit. However, that doesn't to
seem happen, at least not for me, instead it sleeps 5 seconds then
prints 01234 and exits. It this how it's soposed to happen, and if so, why?
------------------------------
Date: 28 Feb 2003 13:12:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: sleep happening at the wrong time.
Message-Id: <b3nn7l$nq9$3@mamenchi.zrz.TU-Berlin.DE>
emcee <res1uzbe@verizon.net> wrote in comp.lang.perl.misc:
> I posted this on comp.lang.perl, before I read a bit and relized its not
> used much anymore:
>
>
> It would seem to me that a code such as the following:
>
> print $i++ while $i<5;
> sleep 5;
>
> Should print 01234, sleep 5 seconds and exit. However, that doesn't to
> seem happen, at least not for me, instead it sleeps 5 seconds then
> prints 01234 and exits. It this how it's soposed to happen, and if so, why?
perldoc -q buffer
Anno
------------------------------
Date: 28 Feb 2003 13:20:24 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: sleep happening at the wrong time.
Message-Id: <b3nnmo$ksi$1@nets3.rz.RWTH-Aachen.DE>
Also sprach emcee:
> I posted this on comp.lang.perl, before I read a bit and relized its not
> used much anymore:
How could it? It does not even exist. Only out-of-date newsservers still
have it. Years ago it was split into this one and
comp.lang.perl.modules.
> It would seem to me that a code such as the following:
>
> print $i++ while $i<5;
> sleep 5;
>
> Should print 01234, sleep 5 seconds and exit. However, that doesn't to
> seem happen, at least not for me, instead it sleeps 5 seconds then
> prints 01234 and exits. It this how it's soposed to happen, and if so, why?
Buffering of the selected output channel. Add
$| = 1;
to the top of your script and your problem should disappear. See
perlvar.pod for details on $| (and other special variables).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 28 Feb 2003 13:28:34 GMT
From: emcee <res1uzbe@verizon.net>
Subject: Re: sleep happening at the wrong time.
Message-Id: <6uJ7a.16870$ES3.1855@nwrddc04.gnilink.net>
Thanks for the help.
> How could it? It does not even exist. Only out-of-date newsservers still
> have it. Years ago it was split into this one and
> comp.lang.perl.modules.
I guess my news server is out of date than, because I poster there
yesterday.
------------------------------
Date: 28 Feb 2003 13:38:19 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: sleep happening at the wrong time.
Message-Id: <b3noob$m0v$1@nets3.rz.RWTH-Aachen.DE>
Also sprach emcee:
> Thanks for the help.
>
>> How could it? It does not even exist. Only out-of-date newsservers still
>> have it. Years ago it was split into this one and
>> comp.lang.perl.modules.
>
> I guess my news server is out of date than, because I poster there
> yesterday.
Yup. It means that the admin of your newsserver is doing a lousy job
(even though I still think that a newsserver carrying groups that don't
officially exist is better than one that misses official groups; not
that one would have a choice between those two though).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Fri, 28 Feb 2003 15:52:53 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: sleep happening at the wrong time.
Message-Id: <b3o0au$2bb$1@news.dtag.de>
emcee wrote:
> I posted this on comp.lang.perl, before I read a bit and relized its not
> used much anymore:
>
>
> It would seem to me that a code such as the following:
>
> print $i++ while $i<5;
> sleep 5;
>
> Should print 01234, sleep 5 seconds and exit. However, that doesn't to
> seem happen, at least not for me, instead it sleeps 5 seconds then
> prints 01234 and exits. It this how it's soposed to happen, and if so, why?
By default STDOUT is buffered. Turn it off and your script will behave
as expected.
->malte
PS: You can turn of buffering by prepending $|++ to your script.
------------------------------
Date: 28 Feb 2003 06:35:45 -0800
From: pete@bostonsucks.org (Pete Keiper-White)
Subject: Using AuthTicket with a Mac?
Message-Id: <888aea98.0302280635.51f5116e@posting.google.com>
So, I have a link to file in a protected area (protected by
AuthTicket). If I link to an HTML file all is fine. However, if I link
to a downloadable file (i.e. a StuffIt file, etc) it comes back with
an error that IE could not load the file. This only happens on Macs
running IE 5.1.6 and lower and it only happens the first time you
click on the file in question. On a PC it always works as desired. Has
anyone else seen this? Any thoughts on how to correct this?
------------------------------
Date: Fri, 28 Feb 2003 14:50:23 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Using AuthTicket with a Mac?
Message-Id: <3e5f76f0.1825262148@news.cis.dfn.de>
On 28 Feb 2003 06:35:45 -0800, pete@bostonsucks.org (Pete
Keiper-White) wrote:
>So, I have a link to file in a protected area (protected by
>AuthTicket). If I link to an HTML file all is fine. However, if I link
>to a downloadable file (i.e. a StuffIt file, etc) it comes back with
>an error that IE could not load the file. This only happens on Macs
>running IE 5.1.6 and lower and it only happens the first time you
>click on the file in question. On a PC it always works as desired. Has
>anyone else seen this? Any thoughts on how to correct this?
Why on earth are you posting this to a Perl newsgroup?
Do you go to a classical music group to discuss chicken
farming?
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Fri, 28 Feb 2003 15:21:36 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Using AuthTicket with a Mac?
Message-Id: <48L7a.44767$ep5.1843@nwrddc02.gnilink.net>
Pete Keiper-White wrote:
> So, I have a link to file in a protected area (protected by
> AuthTicket). If I link to an HTML file all is fine. However, if I link
> to a downloadable file (i.e. a StuffIt file, etc) it comes back with
> an error that IE could not load the file. This only happens on Macs
> running IE 5.1.6 and lower and it only happens the first time you
> click on the file in question. On a PC it always works as desired. Has
> anyone else seen this? Any thoughts on how to correct this?
You may want to try a NG that actually deals with at least some of HTML,
links, downloads, IE Mac, PC, ....
jue
------------------------------
Date: Fri, 28 Feb 2003 15:26:33 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Using AuthTicket with a Mac?
Message-Id: <1fr3mrt.glw9tr1epzifyN%tony@svanstrom.com>
Helgi Briem <helgi@decode.is> wrote:
> On 28 Feb 2003 06:35:45 -0800, pete@bostonsucks.org (Pete
> Keiper-White) wrote:
>
> >So, I have a link to file in a protected area (protected by
> >AuthTicket). If I link to an HTML file all is fine. However, if I link
> >to a downloadable file (i.e. a StuffIt file, etc) it comes back with
> >an error that IE could not load the file. This only happens on Macs
> >running IE 5.1.6 and lower and it only happens the first time you
> >click on the file in question. On a PC it always works as desired. Has
> >anyone else seen this? Any thoughts on how to correct this?
>
> Why on earth are you posting this to a Perl newsgroup?
>
> Do you go to a classical music group to discuss chicken
> farming?
Going to a classical music group discussing chicken farming would just
be silly, but since they've got PEARL CGIs[*] on their webserver they'd
discuss it here...
eh... hmmm... unless they're playing classical music to the chickens,
of course; but AFAIK it's only cows that benefit from classical music,
so playing classical music to chickens would be just as silly as
discussing chicken farming in a classical music group.
[*] just to avoid stupid questions... yes, I wrote it like that as part
of the joke, and yes (again), I'm not serious about this, well, about
the cows I am, you don't mess with cows.
--
# Per scientiam ad libertatem! // Through knowledge towards freedom! #
# Genom kunskap mot frihet! =*= (c) 1999-2002 tony@svanstrom.com =*= #
perl -e'print$_{$_} for sort%_=`lynx -source svanstrom.com/t`'
------------------------------
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 4642
***************************************