[29532] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 776 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 20 16:09:42 2007

Date: Mon, 20 Aug 2007 13:09:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 20 Aug 2007     Volume: 11 Number: 776

Today's topics:
        MI5 Persecution: Continuing Silence 9/5/97 (15627) MI5Victim@mi5.gov.uk
        MI5 Persecution: David Hepworth (2) 16/5/97 (18073) MI5Victim@mi5.gov.uk
        MI5 Persecution: Ken Clarke (1), April 1997 (2174) MI5Victim@mi5.gov.uk
        MI5 Persecution: Overview (951) MI5Victim@mi5.gov.uk
        MI5 Persecution: Peak Practice 26/4/97 (14404) MI5Victim@mi5.gov.uk
        MI5 Persecution: Victor Lewis-Smith 9/5/97 (16850) MI5Victim@mi5.gov.uk
        On redhat, different users = different @INC <russell.brooks@perdue.com>
    Re: On redhat, different users = different @INC <mritty@gmail.com>
        optimizing text file searches <mbuttner@gmail.com>
    Re: optimizing text file searches <wahab@chemie.uni-halle.de>
    Re: optimizing text file searches <mbuttner@gmail.com>
    Re: optimizing text file searches <brian.helterline@hp.com>
        Perl sum of array and help with sorting <davechunny@gmail.com>
    Re: Perl sum of array and help with sorting <mritty@gmail.com>
    Re: set enviorment varibale  chinmoy.chittaranjan@gmail.com
    Re: Stumped: returning a read pipe from a function <socyl@987jk.com.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 20 Aug 2007 18:32:40 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: Continuing Silence 9/5/97 (15627)
Message-Id: <m07072018323758@4ax.com>

Subject: The Continuing Silence
Newsgroups: uk.misc
Organization: Toronto Free-Net
Summary:
Keywords:
 
The silence continues. I am enjoying listening to Radio 4 without any ill
effects whatsoever. Admittedly I am recording every moment, but still. Even
better, I have fished out a recording from ITN last year which at the time I
was convinced had been about me, and on re-seeing it I am now convinced it is
not about me at all.
 
But that is not to disclaim all the many "live incidents" that have happened.
Everything written on my website is true. For the newcomers, its URL (as seen
in the Observer and Private Eye) is
 
[snip]
 .......................................................................
Mike Corley wrote:
> 
> The silence continues. I am enjoying listening to Radio 4 without any ill
> effects whatsoever. 

Already the New Labour govt improves the quality of life of the
populace!


--
To reply by email you must delete the trailing x from the To: field
Why not drop by my web page sometime?  http://www.man.ac.uk/~zlsiida
Manchester's cheapest poker game still needs more players - drop me
a line if interested, or if you know another game that I might like.
 .......................................................................
From: David Roberts <oss108@sos.bangor.ac.yuk>

Mike, you're a ray of sunshine on a cold and miserable day.
Long may the silence continue.

David
-- 
***************================****************
       Right that's enough junk mail.
      If you really want to e-mail me,
       remove the y from my address
 .......................................................................
>better, I have fished out a recording from ITN last year which at the time I 
>was convinced had been about me, and on re-seeing it I am now convinced it is 
>not about me at all.

You've cheered me up with this news, Mike. Seriously. The last sentence 
suggests that your health is improving, and you are beginning to become
pragmatic, in some way...

Take a deep breath, and look to the future. I wish you well.

	Smid
 .......................................................................

15627


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: 20 Aug 2007 19:21:50 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: David Hepworth (2) 16/5/97 (18073)
Message-Id: <m07072019214602@4ax.com>

Subject: David Hepworth (GLR) is taking the piss
Newsgroups: uk.misc
Organization: Toronto Free-Net
Summary:
Keywords:
 
>Last night (21/Feb/97), I was listening to BBC GLR. You have to understand that
>I was listening by stealth. Back in 1990 I used to have Capital blaring out of
 
Not much changes. Today I was listening again to David Hepworth's show on GLR,
having more or less waded in on it by accident. Here is the exchange;
 
David: "we have executive drivetime, we have Brian in charge of the prize
cupboard. Brian it's not a bad prize cupboard this week is it?"
 
Brian: "no David it's an absolute (EMPHASIS) embarrassment (END-EMPHASIS) of
prizes this evening" (laughter)
 
David: "what have we got?"
 
Brian: "well in my left hand alone we've got that .... Gary Clale, I don't know
if you remember him obviously still alive and kicking...."

David: "Rock and roll spelling test is your first opportunity to take advantage
of this embarrassment of prizes"
 
 
What do I read into this exchange? The laughter after the word "embarrassment"
shows they're aware of the last complaint I made on usenet (copied by
snail-mail to them). The "left hand" business is I think a coded way of calling
me a w***er (the term would be better applied to Brian and David).
 
I have a tape of this exchange, and will eventually get around to posting it on
the website.
 ........................................................................
Subject: Re: David Hepworth (GLR) is taking the piss
Newsgroups: uk.misc
References: <E9xMvw.4H2.0.bloor@torfree.net>
Organization: Toronto Free-Net
Distribution: uk
 
I don't understand. Why has nobody replied to this post? You keep on asking for
evidence, then I present you with something that looks very much like evidence,
and everybody just ignores it. OK I haven't posted the actual sound extract,
and it still isn't proof.
 
Perhaps everybody just finds it all too boring and dull. Should I start
spamming again from one of those nice anonymous remailers to wake everyone up?
Now there's a thought.
 ........................................................................
Mike Corley <bu765@torfree.net> wrote:
>I don't understand. Why has nobody replied to this post?

Cos you don't reply to our points - you're ignoring us, why shouldn't
we ignore you?

>You keep on asking for evidence, then I present you with something 
>that looks very much like evidence, 

No you don't, you post something which could _never_, _ever_ be construed
as referring to yourself. Can't you see it? No, of course you can't,
you've an illness.
 
>Perhaps everybody just finds it all too boring and dull. Should I start 
>spamming again from one of those nice anonymous remailers to wake everyone up? 
>Now there's a thought.

And I see you've started. Give it a rest, Mike, unless you're prepared to
enter into proper discussion.

-- 
Illtud Daniel                                      idaniel@jesus.ox.ac.uk
-see Twin Town-                                          -Buy Apollo 440-
 ........................................................................
>Mike Corley <bu765@torfree.net> wrote:
>>I don't understand. Why has nobody replied to this post?

Never read it. Repost?

	Smid
 ........................................................................
In article <5lhg3i$ete@news.ox.ac.uk>,
Illtud Daniel <idaniel@jesus.ox.ac.uk> wrote:
>[reposted]
>
>>Brian: "no David it's an absolute (EMPHASIS) embarrassment (END-EMPHASIS) of 
>>prizes this evening" (laughter)

Uh-Uh. He's on for a bad attack, if he's singling out words which are 
apparently attacking him. He previously restricted himself to just 
dialog about the mentally ill.

TAKE YOUR MEDICATION MIKE. 

	Smid
 ........................................................................

18073


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: 20 Aug 2007 20:09:03 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: Ken Clarke (1), April 1997 (2174)
Message-Id: <m07072020085907@4ax.com>


Ken Clarke (1), April 1997

Certainty level: 30%

The first of two video segments from the same program, this shows
Jon Snow interviewing Ken Clarke in April 1997, during the general
election campaign. The following exchange is heard;

Jon Snow: "You say we are booming in your posters, the bust's around the corner"

Ken Clarke: "You took that from three years ago, when I was being
advised to do all kinds of mad things to stimulate the economy,
and being told that I had to take desperate measures to get it going"

At this time I was watching television almost continuously at home,
with a video recorder whirring away, trying to obtain from the
newscasters a reaction which would give them away. I think this is an
instance where it happened. Ken Clarke first darts a glance straight at
the video camera (and perhaps at a monitor next to it showing my living
room), then comes out with "all kinds of mad things", while engaging in a
facial display involving raising of eyebrows and lowering of eyelids.
To me at the time, and also now, it looked as if he was selecting a
context into which he could drop the word "mad" as a directed insult against me.

2174


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: 20 Aug 2007 19:52:52 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: Overview (951)
Message-Id: <m07072019524828@4ax.com>


Overview

What all these snatches of video and audio, and newspaper articles, have in common is that none of them provide conclusive or very convincing
evidence of their being directed against me, or forming part of a campaign against me. Other people with my illness doubtless could produce similar
non-proof if they were minded to do so.

Good, now we've got the disclaimer out of the way, we can describe precisely what it is that is on display in this part of the site. In the video
section, we have Quicktime (MPEG-4) clips of Jon Snow of ITN in action, also interviews with Ken Clarke and John Major of the ousted Tory regime. These are
embedded in the page using QuickTime. While each audio/video clip is coded to automatically download the QuickTime player, you may find it helpful to
download QuickTime from Apple's website before you start viewing the media files.

Note that each item is awarded a rating of the confidence I feel that it is directed at me, expressed as a percentage. Items with 50% or
more are probably about me; 100% indicates a "dead cert".

In audio we have MP3 files of harassment at work in Canada in late 1996, also GLR's David Hepworth not even trying to pretend that he isn't getting
at me, and a snippet of Capital. There is also an album track which I have taken as being about me. The newspapers section contains articles by Bernard
Levin on his encounter with a madman who "bursts into tears, and swears it is all
true - and it is". Also a Private Eye cover, and snippet from Victor Lewis-Smith.

I have added several recordings of abuse "in public". By Sept/1998 I had seven minidiscs of such recordings, unfortunately containing mostly very
nasty sexual slanders which I will not be publishing on this website. The recordings were made on a Sony Minidisc Walkman MZ-R30, which I purchased
in Canada in July/1997, with ECM-T140 microphone. After both the MZ-R30 and the microphone reached the end of their lives, in June/2001 I purchased as
replacement my current recording gear, an MZ-R900 walkman with ECM-T145 microphone.

Share and Enjoy! I hope you enjoy partaking in my delusions which have been recorded with high fidelity digital equipment and presented for your
listening pleasure.

951


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: 20 Aug 2007 18:12:02 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: Peak Practice 26/4/97 (14404)
Message-Id: <m07072018115950@4ax.com>

Subject: "Peak Practice" 1/4/97 wanted
Newsgroups: uk.misc,rec.arts.tv.uk.misc
Organization: Toronto Free-Net
Summary:
Keywords:
 
 
I am looking for a recording of "Peak Practice" from yesterday 1.April on VHS
tape. Willing to pay a reasonable sum for a recording.
 .................................................................
Mike Corley <bu765@torfree.net> wrote:

>I am looking for a recording of "Peak Practice" from yesterday 1.April on VHS 
>tape. Willing to pay a reasonable sum for a recording.

Uh-oh. Peak Practice slagging you off as well now, eh Mike?

-- 
Illtud Daniel                                      idaniel@jesus.ox.ac.uk
-see Twin Town-                                          -Buy Apollo 440-
 .................................................................
Subject: Re: "Peak Practice" 1/4/97 wanted
Newsgroups: uk.misc,rec.arts.tv.uk.misc
Followup-To: uk.misc,rec.arts.tv.uk.misc
References: <E80u0B.8qD.0.bloor@torfree.net> <5i0onj$c9n@news.ox.ac.uk>
Organization: Toronto Free-Net
Distribution:
 
>Uh-oh. Peak Practice slagging you off as well now, eh Mike?
 
You better believe it. Tuesday's episode had one of its characters being
labelled as a "lunatic" with "something wrong with them". I changed channels
rapidly at this point, but in retrospect perhaps I should have carried on
watching and taped the program.
 
A few days ago I bought a video recorder (about time too) for evidence
gathering purposes. But strangely the TV news (both BBC and ITN) haven't
uttered a sound over the last few days. Almost as if they know they're being
taped...
 .................................................................
Mike Corley <bu765@torfree.net> wrote:
>>Uh-oh. Peak Practice slagging you off as well now, eh Mike?
> 
>You better believe it. Tuesday's episode had one of its characters being
>labelled as a "lunatic" with "something wrong with them".

And?

There are many characters in TV programmes who _are_ lunatics with
'something wrong with them'. Why do you think this alludes to you?

In the eponymous book, Cervantes' Don Quixote is described as 'crazy' 
'mad' and 'lunatic'. Do you think this is a reference to yourself, 
albeit written by a time-travelling 17th century Spaniard?

If you accept that the character of Don Quixote can be described thus
without it being a reference to you, what problem do you have with
Peak Practice? Or do you enjoy tilting at your own little windmills?

A friend's lodger has turned out to be paranoid schizophrenic. Her
obsessions are strikingly similar to yours, she is convinced that she
is being bugged, and that students at her college are making fun of
her for being foreign. She has been looking for the services of a
private detective. Maybe Oxford has this unfortunate effect on foreigners?

I must say that I'm surviving rather well, or that's what the man
under the stairs told me yesterday.
 
-- 
Illtud Daniel                                      idaniel@jesus.ox.ac.uk
-see Twin Town-                                          -Buy Apollo 440-
 .................................................................
So Mike, you are a woman, married to a doctor,have two children, speak
spanish, and living in the Peak District. Is that a fair description of
you?

BAZZA
 .................................................................

14404


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: 20 Aug 2007 18:56:56 GMT
From: MI5Victim@mi5.gov.uk
Subject: MI5 Persecution: Victor Lewis-Smith 9/5/97 (16850)
Message-Id: <m07072018565212@4ax.com>

Victor Lewis-Smith has broken the silence in his TV review column "Goon and 
best forgotten" in the Evening Standard (on Thursday 8/May). He said, "If I 
sound paranoid, that's probably because I once worked there. Eventually, I had 
to leave because they were all trying to kill me but, for sheer pathological 
hatred of the Corporation, I couldn't hold a candle to Spike Milligan".

I take this to be about me, because recently I wrote to both the BBC and 
Capital Radio, saying "I believe the current purpose of the harassment is to 
force me to kill myself to prevent the harassers, yourselves included, from 
being brought to justice, and last year there were several incidents of people 
shouting 'suicide' at me, which would appear to corroborate that view." I think 
VLS's words about the BBC "all trying to kill me" shows he has seen or heard of 
what I sent to the BBC or Capital.

Nasty eh? I believe that VLS or his mates read this newsgroup. I wonder how he 
would explain his article?
 .........................................................................
Date: Fri, 9 May 1997 23:11:40 +0000 (GMT)
From: Webmaster for Victor <vls@bbcradio.demon.co.uk>
To: Mike Corley <bu765@freenet.toronto.on.ca>
Subject: Re: paranoia
 
Dear Mike,
 
Victor's not writing about you.
 
Yours,
 
John Hayward-Warburton
Victor's Webmaster
 .........................................................................
For some reason, I don't quite believe you. It's just too close a match.
 .........................................................................
In article <E9xG0x.Gtr.0.bloor@torfree.net>,
Mike Corley <bu765@torfree.net> wrote:
>Victor Lewis-Smith has broken the silence in his TV review column "Goon and 
>best forgotten" in the Evening Standard (on Thursday 8/May). He said, "If I 
>sound paranoid, that's probably because I once worked there. Eventually, I had 
>to leave because they were all trying to kill me but, for sheer pathological 
>hatred of the Corporation, I couldn't hold a candle to Spike Milligan".

Erm, Mike, I'm a bit of a fan of Victor Lewis-Smith, ever since his days
of "BuyGones". I must admit, he often likes to play the flawed lunatic
evil nasty person. He's been doing it for years, with prank calls, far
before your illness. Its his act. He wouldn't be VLS without it.

He doesn't like the "Goons" either. It isn't about you.

>I take this to be about me, because recently I wrote to both the BBC and 
>Capital Radio, saying "I believe the current purpose of the harassment is to 
>force me to kill myself to prevent the harassers, yourselves included, from 
>being brought to justice, and last year there were several incidents of people 
>shouting 'suicide' at me, which would appear to corroborate that view." I think
>VLS's words about the BBC "all trying to kill me" shows he has seen or heard of
>what I sent to the BBC or Capital.

I don't think Victor Lewis-Smith has worked for the BBC (or Capital) for
several years (1994 was the last time...), so the connection, is paranoia 
here. 

Personally, I believe VLS as a person of reasonable integrity, who wouldn't
give a fuck about you...

>Nasty eh? I believe that VLS or his mates read this newsgroup. I wonder how he 
>would explain his article?

Keep up the medication, not as many people read this newsgroup as you think,
even though you are now incorporating that into your illness.

Victor? Are you there?

	Smid
 .........................................................................

16850


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access


------------------------------

Date: Mon, 20 Aug 2007 12:00:34 -0700
From:  Russ <russell.brooks@perdue.com>
Subject: On redhat, different users = different @INC
Message-Id: <1187636434.682093.27920@19g2000hsx.googlegroups.com>

Hi,

We have RedHat 4EL and perl 5.8.5.  Per a user's request I installed
Date:Simple, using 	perl -MCPAN -e shell
as the root user.
Now root can find Date::Simple, but other users cannot.  They do not
want to include a lib statement in their scripts or invoke with a -I.
The @INC libraries are close, but not identical.

Does anyone know how to correct or resolve this?
Any suggestions would be appreciated.

Best regards,
Russ



------------------------------

Date: Mon, 20 Aug 2007 12:07:52 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: On redhat, different users = different @INC
Message-Id: <1187636872.267520.89150@r29g2000hsg.googlegroups.com>

On Aug 20, 3:00 pm, Russ <russell.bro...@perdue.com> wrote:

> We have RedHat 4EL and perl 5.8.5.  Per a user's request I
> installed Date:Simple, using      perl -MCPAN -e shell
> as the root user.
> Now root can find Date::Simple, but other users cannot.  They
> do not want to include a lib statement in their scripts or
> invoke with a -I. The @INC libraries are close, but not
> identical.
>
> Does anyone know how to correct or resolve this?
> Any suggestions would be appreciated.

In their .profile (or .bash_profile, or whatever), set the PER5LIB
variable to the path of the installed modules.

export PERL5LIB=/path/to/modules/
or
setenv PERL5LIB /path/to/modules
(depending on the shell in use...)

Paul Lalli



------------------------------

Date: Mon, 20 Aug 2007 18:15:35 -0000
From:  bivity <mbuttner@gmail.com>
Subject: optimizing text file searches
Message-Id: <1187633735.495944.223950@i13g2000prf.googlegroups.com>

My work requires a lot of index lookups for large amounts of files
daily. Recently, we have been receiving files with one document per
line along with all its attributes. This file will have around 400,000
entries. I then receive another file, with just the file name, and I
am told, look for each one of these files in this 400,000 entry list.
There are about 5000 in the file.

I just wrote a quick script to meet my needs, where I read in both
files, and grep (search_item, content_file). It works pretty well.
Except, it takes about 25 minutes for 5000 entries. I can't use a hash
implementation here, is there a way I can make this search faster?

Below is a sample search term and what the index line looks like,
along with the entire script. I know its rough, but i wrote it in a
hurry and I would like to refine it now, make it faster.

Search File Term:
885_Addm Un Lse 0867.pdf

Large File to be searched, its matching index:
"885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse
0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse
0867"

script:

#!/usr/local/bin/perl
open(FILE, $ARGV[0]);
my @text_rep=<FILE>; #file to search
close FILE;
open(FILE, $ARGV[1]);
my @text_search=<FILE>; #file with entries to use in search
close FILE;
print "Size of content:". @text_rep ."\n";
print "Searching for".@text_search. "instances\n";
open (OUT, "+>did_not_find.txt"); # in case grep can't find the value,
log it
foreach my $query (@text_search)
{
  chomp($query);
  $query =~s/\(/\./;
  $query =~s/\)/\./;
  $query =~s/\$/\./;
  my @qu = grep(/$query/,@text_rep);
  if($qu[0] eq '') {
  print OUT $query."\n";}#Error Logging
  else{
  push(@final,$qu[0]);}#Found, so place in array
}
close OUT;
open (OUT, "+>lines_that_pulled.txt");
print OUT @final;
close OUT;



------------------------------

Date: Mon, 20 Aug 2007 20:36:44 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: optimizing text file searches
Message-Id: <facnc2$12a1$1@nserver.hrz.tu-freiberg.de>

bivity wrote:
> Search File Term:
> 885_Addm Un Lse 0867.pdf

That means, you do each search on
4-5000 times (exactly such lines)
against:

> Large File to be searched, its matching index:
> "885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse
> 0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse
> 0867"

Is this (above) *one line*, eg.:

"885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse 0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse 0867"

delimited by '\n' from the following line?

Regards

M.


------------------------------

Date: Mon, 20 Aug 2007 19:31:05 -0000
From:  bivity <mbuttner@gmail.com>
Subject: Re: optimizing text file searches
Message-Id: <1187638265.512233.216040@z24g2000prh.googlegroups.com>

On Aug 20, 1:36 pm, Mirco Wahab <wa...@chemie.uni-halle.de> wrote:
> bivity wrote:
> > Search File Term:
> > 885_Addm Un Lse 0867.pdf
>
> That means, you do each search on
> 4-5000 times (exactly such lines)
> against:
>
> > Large File to be searched, its matching index:
> > "885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse
> > 0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse
> > 0867"
>
> Is this (above) *one line*, eg.:
>
> "885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse 0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse 0867"
>
> delimited by '\n' from the following line?
>
> Regards
>
> M.

Yes,I know, I am linear searching, big O of (N*n)
N being the lines in the input file
n being lines in a file to search
Which isn't efficient when we are talking 400k and 5k items. It was
just the quick and dirty way I knew, and like to see if there is
better way to do this.

Each line in both files only contains one instance and yes it's
delimited by \n, Solaris - SunOs 5.8 environment, Perl version 5.8, I
can't use any extended libraries as well.

Thanks for the help in advance.



------------------------------

Date: Mon, 20 Aug 2007 12:34:28 -0700
From: Brian Helterline <brian.helterline@hp.com>
Subject: Re: optimizing text file searches
Message-Id: <facqc4$8t0$1@usenet01.boi.hp.com>

bivity wrote:
> My work requires a lot of index lookups for large amounts of files
> daily. Recently, we have been receiving files with one document per
> line along with all its attributes. This file will have around 400,000
> entries. I then receive another file, with just the file name, and I
> am told, look for each one of these files in this 400,000 entry list.
> There are about 5000 in the file.
> 
> I just wrote a quick script to meet my needs, where I read in both
> files, and grep (search_item, content_file). It works pretty well.
> Except, it takes about 25 minutes for 5000 entries. I can't use a hash
> implementation here, is there a way I can make this search faster?

why not a hash?  It is the right tool for the job.
> 
> Below is a sample search term and what the index line looks like,
> along with the entire script. I know its rough, but i wrote it in a
> hurry and I would like to refine it now, make it faster.
> 

with grep, you search through the entire array of entries and
create an array of matches but only print the first entry found.
This seems very wasteful, especially if the first match is on line 1.


> Search File Term:
> 885_Addm Un Lse 0867.pdf
> 
> Large File to be searched, its matching index:
> "885_Addm Un Lse 0867.pdf","885","ELM 111 N BOBBY AVE","Addm Un Lse
> 0867","Addm Un Lse 0867.pdf","Elmhurst","651","885","885_Addm Un Lse
> 0867"
> 
> script:
> 
> #!/usr/local/bin/perl
> open(FILE, $ARGV[0]);
> my @text_rep=<FILE>; #file to search
> close FILE;
> open(FILE, $ARGV[1]);
> my @text_search=<FILE>; #file with entries to use in search
> close FILE;
> print "Size of content:". @text_rep ."\n";
> print "Searching for".@text_search. "instances\n";
> open (OUT, "+>did_not_find.txt"); # in case grep can't find the value,
> log it
> foreach my $query (@text_search)
> {
>   chomp($query);
>   $query =~s/\(/\./;
>   $query =~s/\)/\./;
>   $query =~s/\$/\./;

you are substituting one metachar for another in your regular 
expression. Read up on the \Q & \E operators in perlre so
you won't have to use the above 3 lines.  You can also improve the 
search by anchoring it to the beginning of the line if you are just 
looking for filenames preceeded by a quotation mark.

>   my @qu = grep(/$query/,@text_rep);

my @qu = grep( /^"\Q$query/, @text_rep );

>   if($qu[0] eq '') {
>   print OUT $query."\n";}#Error Logging
>   else{
>   push(@final,$qu[0]);}#Found, so place in array
> }
> close OUT;
> open (OUT, "+>lines_that_pulled.txt");
> print OUT @final;
> close OUT;
> 

-- 
brian


------------------------------

Date: Mon, 20 Aug 2007 19:44:12 -0000
From:  elroyerni <davechunny@gmail.com>
Subject: Perl sum of array and help with sorting
Message-Id: <1187639052.581261.187360@i38g2000prf.googlegroups.com>

Hi -

I have a array of a list of numbers:

 7.9216
 8.7583
 12.675
 0.8028
 6.9230
 1.1403
 6.0083
 0.1454

I wrote a sub-routine to add the list, but i'm getting these syntax
errors, and was wondering if someone could tell me what i'm doing
wrong. here's my code for the sub-routine:
sub sum_array {
    my($sum) = 0;       # initialize the sum to 0
    foreach $i (@array_data) {
        $sum = $sum + $i;
    }
    return($sum);
}

It's returning this error: isn't numeric in addition (+)

Also I'm trying to write a sub-routine that will go through each
element in the array and tell me how many elements in the array are
less than a given value. For example in the array above say i want to
return the amount of elements that are less than 5 seconds. From the
array above I'd return 3.Here's what I have so far:
sub less_five {
foreach $r(@array_data){
count=0;
while ($count<5)
{
 $count++;
}
}
return($data);
}

Cant seem to get this to work.. Thanks for your help!



------------------------------

Date: Mon, 20 Aug 2007 12:56:25 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Perl sum of array and help with sorting
Message-Id: <1187639785.632883.182450@w3g2000hsg.googlegroups.com>

On Aug 20, 3:44 pm, elroyerni <davechu...@gmail.com> wrote:
> Hi -
>
> I have a array of a list of numbers:
>
>  7.9216
>  8.7583
>  12.675
>  0.8028
>  6.9230
>  1.1403
>  6.0083
>  0.1454
>
> I wrote a sub-routine to add the list, but i'm getting these syntax
> errors, and was wondering if someone could tell me what i'm doing
> wrong. here's my code for the sub-routine:
> sub sum_array {
>     my($sum) = 0;       # initialize the sum to 0
>     foreach $i (@array_data) {
>         $sum = $sum + $i;
>     }
>     return($sum);
>
> }
>
> It's returning this error: isn't numeric in addition (+)

Okay, first of all, that's a warning, not an error.  In any event,
basically this means your array's contents aren't what you think they
are.  You have at least one non-numeric element in that array.  To see
exactly what's in it, use these lines:

use Data::Dumper;
print Dumper(\@array_data);


> Also I'm trying to write a sub-routine that will go through each
> element in the array and tell me how many elements in the array are
> less than a given value. For example in the array above say i want to
> return the amount of elements that are less than 5 seconds. From the
> array above I'd return 3.Here's what I have so far:
> sub less_five {
> foreach $r(@array_data){
> count=0;
> while ($count<5)
> {
>  $count++;
>
> }
> }
> return($data);
> }
>
> Cant seem to get this to work.

Your logic on this one mystifies me.  I don't at all understand what
the while loop is supposed to do, nor do I understand where $data came
from.   This is a lot simpler than you're making it:

sub less_five {
   my $count;
   foreach my $r (@array_data) {
      if ($r < 5) {
         $count++;
      }
   }
   return $count;
}

or, much more simply:

my $count = grep { $_ < 5 } @array_data;

Paul Lalli




------------------------------

Date: Mon, 20 Aug 2007 18:46:35 -0000
From:  chinmoy.chittaranjan@gmail.com
Subject: Re: set enviorment varibale
Message-Id: <1187635595.891859.211330@m37g2000prh.googlegroups.com>

On Aug 20, 8:10 am, j...@toerring.de (Jens Thoms Toerring) wrote:
> chinmoy.chittaran...@gmail.com wrote:
> >             I am very new to perl .Actually i want to set a enviorment
> > variable thorugh perl script .
> > e.g.->set build =1;means this variable will be set by my perl script.
> > So could you please help on this matter ?
>
> As you has been told to set an environment variable assign to the
> %ENV hash. But the way you write it I suspect that you want to set
> an environment variable in the shell (or other process) you called
> the script from, using that script. And that's something that can't
> be done, you can only set an environment variable for the process
> you're currently running (and for the child processes it may start
> later) but never for its parent process, i.e. the process that
> started the script.
>                                Regards, Jens
> --
>   \   Jens Thoms Toerring  ___      j...@toerring.de
>    \__________________________      http://toerring.de
sorry for that if i sent 2 many messages before that beause i am
facing some problem regarding internet.
Too much Thanks Gunner ..it is working fine .But if i want to set this
enviorment variable to nothing (mean set build=1 to nothing)then what
procedure i have to follow?



------------------------------

Date: Mon, 20 Aug 2007 20:04:26 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Re: Stumped: returning a read pipe from a function
Message-Id: <facs4a$mja$1@reader1.panix.com>

In <1187560775.289330.169730@m37g2000prh.googlegroups.com> "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com> writes:

> open my $in, '-|', '/some/command 2>&1', @args
>             or die $!;

> my $line = <$in>;
> if ( eof($in) ) {
>    die $line, " close error:", $! || $?
>          unless close($in);
> }

> return $in, $line;

Well, of all the bazillion variants I've coded and tested in the
last couple of days, the one based on this idea is the one that
works the best.  Thank you very much.

Still, there's something a bit odd about the resulting routine:

  use IPC::Open3 'open3';
  use IO::Unread 'unread';

  sub foo {
    my $pid =
      open3( my ( $wtr, $rdr, $err ), '/some/command', @_ );

    close $wtr;

    if ( defined ( my $first_line = <$rdr> ) ) {
      die $first_line if eof( $rdr );
      unread $rdr, $first_line;
    }
    return $rdr;
  }

The oddity is that $err is not used!  Inexplicably, if I use open3,
errors appear via $rdr, not via $err, as one would expect.  (For
the record, when I run '/some/command' from the command line the
behavior is exactly what one would reasonably expect: errors get
sent to stderr, and normal output gets sent to stdout.)

Furthermore, given the behavior I just described for open3, one
would expect that open2 would work just as well, but this is not
the case.  When I use open2, the error goes to STDERR, which now
is not being caught!

This is crazy.

(If anyone has a clue as to what could be going on here, I'd love
to read about it.  FWIW, the OS here is Linux.)


Lastly, thanks for all your comments and suggestions.  They were
very helpful.

kj

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.


------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 776
**************************************


home help back first fref pref prev next nref lref last post