[13475] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 885 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 23 09:07:24 1999

Date: Thu, 23 Sep 1999 06:05:12 -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: <938091912-v9-i885@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 23 Sep 1999     Volume: 9 Number: 885

Today's topics:
    Re: (-d $filename) test (Kragen Sitaker)
    Re: ./  -- why? (Randal L. Schwartz)
        applications of perl ?? <vishx@mailcity.com>
    Re: automatic news poster script <gellyfish@gellyfish.com>
    Re: automatic news poster script <gellyfish@gellyfish.com>
    Re: automatic news poster script <info@job-base.com>
        beauty of a Y2K bug (Randal L. Schwartz)
        Example commandline programs in perl tad3@my-deja.com
    Re: Example commandline programs in perl <jkline@one.net>
    Re: extract contents of .gz files (Kragen Sitaker)
        get newest file in a dir and write this filename in a f (Pino Calzo)
    Re: get newest file in a dir and write this filename in <rhomberg@ife.ee.ethz.ch>
    Re: get newest file in a dir and write this filename in (Pino Calzo)
    Re: How to validate a URL? <gellyfish@gellyfish.com>
        HTML to ASCII <cyrille@ktaland.com>
        new to Perl- Activestate's PDK wont install <th@funk.karoo.co.uk>
    Re: Newbie question: modules <gellyfish@gellyfish.com>
        Perl and GTK <goralg@friko2.onet.pl>
    Re: REQ: tell-a-friend script <camerond@mail.uca.edu>
    Re: Send doubles over a network <rhomberg@ife.ee.ethz.ch>
    Re: SSH (M.J.T. Guy)
        Unix password parser pkey@sghms.ac.uk
    Re: Usenet threading code? <mike@crusaders.no>
    Re: Win32::ODBC.pm hangs CGI.pm under Apache cmsps@my-deja.com
    Re: Win32::ODBC.pm hangs CGI.pm under Apache (Kragen Sitaker)
    Re: You should be admired (Kragen Sitaker)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 23 Sep 1999 12:36:22 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: (-d $filename) test
Message-Id: <a9pG3.4821$QJ.337218@typ11.nn.bcandid.com>

In article <MPG.12531c0584a6b906989fc0@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Yes.  But fixing it by changing to opendir(CURRENTDIR, '.') won't fix 
>the problem either.  When it bounces back from the first recursion, the 
>current directory will be wrong for the subsequent recursions.

You mean because it might be recursing down a symlink and chdir('..')
might not work?  Or because the recursion might be on '.' or '..', in
which case chdir('..') won't work?  Or what?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 23 Sep 1999 05:30:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: ./  -- why?
Message-Id: <m1g105x12q.fsf@halfdome.holdit.com>

>>>>> "Philip" == Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> writes:

Philip> 2) This opens yourself up to things such as your favourite co-worker
Philip> putting a shell script containing "rm -rf *" and called "ls" into your
Philip> directory. '.' shouldn't be the first component of your path, and
Philip> probably shouldn't be in it at all.

Speaking of cargo cult programming... why do people type:

	rm -rf *

when it should be

	rm -rf .

?  You wanna leave the dotfiles or something?

:-)

print "Just another Perl hacker,"

-- 
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: Thu, 23 Sep 1999 15:54:29 +0530
From: S Vishwanath <vishx@mailcity.com>
Subject: applications of perl ??
Message-Id: <37E9FFDD.BD0EAA98@mailcity.com>

can some body help me by elaborating the exact nature of use of perl
(especially in vlsi design) .

~vishwanath



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

Date: 23 Sep 1999 11:14:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: automatic news poster script
Message-Id: <37e9fd71_1@newsread3.dircon.co.uk>

Job-Base <info@job-base.com> wrote:
>                                              Please see the
> alt.jobs/uk.jobs.contract, .... these groups accept this kind of
> submission.
> 

I really dont care about alt.jobs but :

[from <http://www.usenet.org.uk/hierarchy.html>]

   13. uk.jobs.*

   For employment opportunities offered or wanted. These are UK newsgroups
   and should only be used in relation to employment within the UK,
   or by UK-based companies.

   ...

   Charter of Uk.Jobs.Contract

   (Not Moderated)

   This newsgroup is for placement of advertisements for contractors. These
   contractors can be any temporary staff, including but not limited to
   computer programers, analysts, consultants and project managers.

   Advertisements from agencies, individuals or other companies are welcome. 

   The group's language is English. 

   Newsgroups line

   uk.jobs.contract	Contract positions wanted/offered.  No discussion


I dont see anything there that would indicate that this group is inviting
you to dump your vacancies database to it every week and looking at the
group I get the impression that this is not a common practice there.  Perhaps
I am wrong about this of course - you ought to ask in the group
uk.jobs.d or uk.net.management first.

/J\
-- 
"Teletext - the information super B-road" - Exclusive, Channel 5


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

Date: 23 Sep 1999 11:36:22 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: automatic news poster script
Message-Id: <37ea02a6_1@newsread3.dircon.co.uk>

Job-Base <info@job-base.com> wrote:
> 
> 
> Jonathan Stowe wrote:
>> I came here on a train not a banana boat.  I know you will found out
>> somehow whether it is here or elsewhere - your domain has been duly noted.
> 
> ... and ??? can I expect a postcard for Christmas ?
> 

See my response to your other post.

Of course if you had explained what it was that you were trying to do then
the response might have been different - it might not have been any more
positive but it would have been different.

/J\
-- 
"My codpiece layeth awkwardly across the nadgers" - Declan Donnelly


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

Date: Thu, 23 Sep 1999 14:08:45 +0200
From: Job-Base <info@job-base.com>
Subject: Re: automatic news poster script
Message-Id: <37EA184D.B282FEAE@job-base.com>

FYI,
a) We carry mostly UK jobs (see the site)
b) We have already had contact with their moderator

Anything else ?

> I am wrong about this of course - you ought to ask in the group
> uk.jobs.d or uk.net.management first.


-- 
Michael R.C. De Coninck
michaeldc@job-base.com
T: +32 2 270.45.74
F: +32 2 270.45.75
C: +32 75 47.62.10
http://www.job-base.com
http://www.c-ware.net


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

Date: 23 Sep 1999 05:45:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: beauty of a Y2K bug
Message-Id: <m1btatx0cp.fsf@halfdome.holdit.com>


OK, for grins, I typed in:

	"perl" and ("19 yr" or "19 year")

into Altavista advanced, and got this hit amongst 266 pages:

    if ($Year > 95) {
	$Year = "19$Year"; 
    }
    elsif ($Year < 10) {
	$Year = "200$Year"; 
    }
    else {
	$Year = "20$Year"; 
    }

($Year comes from localtime() of course.)  This stuff is scary.  How
much can one NOT read the documentation?!

And this stuff is all over.  No telling how many scripts are available
in those "free download" areas but not indexed by the spiders.

I'd say anybody that chipped their CGI teeth on either Selena Sol or
Matt Wright's stuff (both of which seem to do stuff like the above),
and didn't eventually turn to the docs, is writing a lot of CRAP(tm)
that will need correcting in less than 100 days.

I know, it's not Perl's fault.  Blame it on the web. :)

print substr "Just another Perl hacker, since 19$year", 0, 25;

-- 
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: Thu, 23 Sep 1999 12:33:15 GMT
From: tad3@my-deja.com
Subject: Example commandline programs in perl
Message-Id: <7sd6mb$252$1@nnrp1.deja.com>

Hi,
  I'm a system admin with a little perl under my belt.  I'm looking for
commandline programs examples, book recommendations, etc., to replace
sed/grep/awk/shell stuff. I know perl is extremely efficient and in the
right hands can be used to do what the other stuff can do.  I've
searched comp.*.perl.* on deja and web without much success.  My reason
for such a request comes from an article in sysadmin with lots of good
examples, I've lost that issue and the "online" version doesn't have
it.


Thanks,

Tom De Boeser


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 23 Sep 1999 08:59:36 -0400
From: Joe Kline <jkline@one.net>
To: tad3@my-deja.com
Subject: Re: Example commandline programs in perl
Message-Id: <37EA2438.E586EE02@one.net>

[posted and mailed]

tad3@my-deja.com wrote:
> 
> Hi,
>   I'm a system admin with a little perl under my belt.  I'm looking for
> commandline programs examples, book recommendations, etc., to replace
> sed/grep/awk/shell stuff. I know perl is extremely efficient and in the
> right hands can be used to do what the other stuff can do.  I've
> searched comp.*.perl.* on deja and web without much success.  My reason

'perldoc perlrun' lists all of the command line switches useful for
creating "one-liners".

'perldoc perlre' does a good job explaining about Perl's regular
expressions.

'perldoc perl' lists all of the online documentation that comes with
Perl installations.

That is assuming you are talking about writing simple scripts just on
the command line. Otherwise, get the fine books (5 camels) mentioned
at:

http://www.perl.com/pub/language/critiques/index.html

joe


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Thu, 23 Sep 1999 12:48:11 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: extract contents of .gz files
Message-Id: <fkpG3.4858$QJ.338282@typ11.nn.bcandid.com>

In article <slrn7ujif7.p4q.dave@ribbit.vfrogs.com>,
Dave Bailey <dave@ribbit.vfrogs.com> wrote:
>On 23 Sep 1999 02:50:36 GMT, BLUESRIFT <bluesrift@aol.com> wrote:
>>I'm a beginner learning and experimenting with Perl on Hypermart.  Hypermart
>>apparently automatically updates a raw.gz log...
>
>Try Compress::Zlib on www.cpan.org; it's a Perl module which 
>provides you with an API for reading and writing gzipped files.

It might be more convenient to open RAWDATA, "gzip -dc '$filename' |"
or die "can't open pipe on $filename: $!".
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 11:12:09 GMT
From: pcalzo@boerse.ch (Pino Calzo)
Subject: get newest file in a dir and write this filename in a file
Message-Id: <37ea09b1.15089875@news.uni-stuttgart.de>

Hi,

I would need help from the experts:

Have the following task and don't really know whether it would be
better to do it with perl or unix shelll script.

Here's the task:


There are several files in a directory, called idn_17.aml, idn_33.aml
or similar. The number differs but is not auto-increasing. What i
would need to do is parse the directory for the idn_*.aml with the
newest date and grab this filename.


the next task is then to replace the idn_oldnumber.aml in some other
file with the new filename.

Any help deeply appreciated!

kind regards from Switzerland


Pino Calzo


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

Date: Thu, 23 Sep 1999 13:29:05 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
To: Pino Calzo <pcalzo@boerse.ch>
Subject: Re: get newest file in a dir and write this filename in a file
Message-Id: <37EA0F01.9CC8992E@ife.ee.ethz.ch>

Pino Calzo wrote:
> 
> Hi,
> 
> I would need help from the experts:
> 
> Have the following task and don't really know whether it would be
> better to do it with perl or unix shelll script.
> 
> Here's the task:
> 
> There are several files in a directory, called idn_17.aml, idn_33.aml
> or similar. The number differs but is not auto-increasing. What i
> would need to do is parse the directory for the idn_*.aml with the
> newest date and grab this filename.

ls -1t idn_*.aml|head -1
sorts by date (-t), gives the first file 

> the next task is then to replace the idn_oldnumber.aml in some other
> file with the new filename.

don't know what you want to do here. But I'm pretty sure you can do it
yourself in sh (or perl) after studying some documentation. 

> kind regards from Switzerland
I thought it was written "Swaziland" :-)

- Alex


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

Date: Thu, 23 Sep 1999 11:36:18 GMT
From: pcalzo@boerse.ch (Pino Calzo)
Subject: Re: get newest file in a dir and write this filename in a file
Message-Id: <37ea1005.16710595@news.datacomm.ch>

On Thu, 23 Sep 1999 13:29:05 +0200, Alex Rhomberg
<rhomberg@ife.ee.ethz.ch> wrote:

>Pino Calzo wrote:
>> 
>> Hi,
>> 
>> I would need help from the experts:
>> 
>> Have the following task and don't really know whether it would be
>> better to do it with perl or unix shelll script.
>> 
>> Here's the task:
>> 
>> There are several files in a directory, called idn_17.aml, idn_33.aml
>> or similar. The number differs but is not auto-increasing. What i
>> would need to do is parse the directory for the idn_*.aml with the
>> newest date and grab this filename.
>
>ls -1t idn_*.aml|head -1
>sorts by date (-t), gives the first file 
>
>> the next task is then to replace the idn_oldnumber.aml in some other
>> file with the new filename.
>
>don't know what you want to do here. But I'm pretty sure you can do it
>yourself in sh (or perl) after studying some documentation. 

now, the output should be put in a variable for later use. i need to
write the filename into a second file (actually scan the file and
replace the current .aml file with the newest one.

>> kind regards from Switzerland
>I thought it was written "Swaziland" :-)

:)
>
>- Alex



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

Date: 23 Sep 1999 12:07:58 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to validate a URL?
Message-Id: <37ea0a0e_1@newsread3.dircon.co.uk>

Paul Carter <couton@bigfoot.com> wrote:
> Tom Phoenix <rootbeer@redcat.com> wrote in message
> news:Pine.GSO.4.10.9909151045290.25903-100000@user2.teleport.com...
>> On Wed, 15 Sep 1999, Mark wrote:
>>
>> > > My friends Fred and Barney would like you to write to them at this
>> > > (valid) address:
>> > >
>> > >     <"fred and barney"(.@..@,,)@redcat.com>
>> >
>> > Bad and all as the check is, it does look for double @'s so this
>> > address would fail.
>>
>> That's my point; the address is valid.
>>
>> > Note, if the addr matches the above RE, it is
>> > invalid, not 'tother way round.
>>
>> One of us is missing something. If an address matches the pattern in the
>> original message, it may or may not be an invalid address. No?
>>
> What I am doing is writing some scripts to act like bravenet.com
> But, I want to make sure that they enter a valid e-mail address and a valid
> URL for their site.
> 
> So, for the e-mail address.. it's pretty much valid if it doesn't contain
>  .@.
>  ..
>  ,
>  )
>  &
>  ?
>  >
>  " "  (space)


Err no.  a valid e-mail address can contain any of those characters as far 
as I can determine - on the host-specific part anyhow.

/J\
-- 
"Shhh! They're strapping down Liza Minelli" - Lisa Simpson


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

Date: Thu, 23 Sep 1999 13:32:31 +0200
From: Cyrille <cyrille@ktaland.com>
Subject: HTML to ASCII
Message-Id: <37EA0FCF.86A26BD4@ktaland.com>

Hi,
I want to converte HTML to ASCII,

but modules :
    use HTML::FormatText ;
    use HTML::Parse;

doesn't parse TABLE !

Is there a another way ? Another module or script ?

Thanx,
Cyrille.






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

Date: Thu, 23 Sep 1999 12:47:31 +0100
From: "Jims News" <th@funk.karoo.co.uk>
Subject: new to Perl- Activestate's PDK wont install
Message-Id: <7sd3st$o7a$1@newsreader2.core.theplanet.net>

Hi,
For my computing degree I am required to learn a bit of Perl. I would like
to use ActiveState's Perl Development Kit for Win32

I have installed Active Perl and DCOM98 (Im running win98 btw), and at the
last hurdle things have gone strange. When i choose to install PDK 1.2 (just
got the latest last night) I went through the screens, choosing where to
install it (same dir as ActivePerl), selecting the options (all except the
WinNT option) then click Next.
Now Im at the point where you usually see a progress bar, indicating that it
is installing, but there is none, just the blue install screen, with 'Perl
Development Kit 1.2' (or similar) at the top left.
I can hear some disk activity, but it is intermittent, and nothing is
happening on screen. After about 10 minutes I figure something is wrong, and
try to close the window, but I cant, so I have to do a soft reset.

Can anyone of you good people help?

Thanks,
 Jim




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

Date: 23 Sep 1999 12:37:12 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Newbie question: modules
Message-Id: <37ea10e8_1@newsread3.dircon.co.uk>

LinksNetwork Admin <andrew@linksnetwork.com> wrote:
> Hi All,
> 
> I have been searchiong high and low for a good tutorial on modules.
> Basically I want to be able to retrieve a URL through my program (for link
> validation), and according to the FAQ, the module LWP is the best way to do
> this.   I downloaded it from CPAN in the hope that it was a simple case of
> putting the module in the same directory as the script, but the zip file I
> downloaded contained a whole directory structure, hundreds of files, more
> than one LWP.pm, and I have no idea how to even start.
> 
> HELP!
> 

Follow the instructions in the README file - thats why its called that.

/J\
-- 
"People say money brings its own problems. Rubbish, rubbish - I'm loaded -
it's fantastic" -


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

Date: Thu, 23 Sep 1999 14:14:26 +0200
From: "G.G." <goralg@friko2.onet.pl>
Subject: Perl and GTK
Message-Id: <37EA19A1.3B3124FB@friko2.onet.pl>

Hi!
I am looking for links to documents (manuals, FAQ etc) about using GTK
in Perl programs.

Thanks in advance!
Grzegorz



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

Date: Thu, 23 Sep 1999 07:52:51 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: REQ: tell-a-friend script
Message-Id: <37EA22A3.30B265FD@mail.uca.edu>

Martien Verbruggen wrote:
> 
> [snip]
> 
> My point being that elsif is not English. It's Perl. And therefore it
> does not have to obey English spelling rules. Perl often does, but
> there is no requirement for it. It might as well have been foogleblurb
> or fidgetygit. It's just easier to remember elsif. If the designers of
> the language had good reasons to prefer elsif above elseif, then they
> are right. If they had decided that gargleblaster was more valid, they
> still would have been right. Maybe less so, but still :)

They may have been in violation of some copyright law, however. Isn't a
gargleblaster something from "The Hitchhiker's Guide to the Galaxy"
series, maybe one of Zaphod's special drinks? (Don't have my copy here
at work)

Cameron

-- 
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu


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

Date: Thu, 23 Sep 1999 12:45:57 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Send doubles over a network
Message-Id: <37EA04E5.9C7EE4BA@ife.ee.ethz.ch>

[courtesy cc mailed]

dieter.heiliger@gmx.de wrote:
> I want to receive data sent by a Windows NT C++ program via a perl
> script. Everything works fine except for floating point numbers. The C++
> program converts the data to network byte order before sending it using
> a socket.
> 
> What I do is the following: I receive data from the socket and unpack
> the whole thing into variables. The data structure sent by the C++
> program includes strings, longs and doubles. Strings and longs work
> fine, but not doubles. When I print the variable that I got from the
> unpack the figure displayed has nothing to do with the figure that I
> sent from the C++ program.

Normally, it should have something to do with the original figure: 
there are different tribes of indians involved: A double has 8 bytes,
all of them get converted to network order: 12345678. 
You need host order. If you convert ints, you get 43218765. What you
need is 87654321. Back to my original statement: the number you get is
the original with first and second 32 bit exchanged.

To relate this to perl (my first try at pack :)

to unpack a double from the network, use the following function:

sub unpacknetdouble {
  use Config;
  my $packed = shift;
  return unpack "d", $packed if $Config{byteorder} =~/4321/; #big endian
  return unpack "d", pack "LL", reverse unpack "N2", $packed; #little
endian
}
$_ = pack "H*", "400a28f5c28f5c29"; # 3.27 in hex on my sun
print unpacknetdouble($_);  # prints 3.27 on both sun and alpha

- Alex

PS: Sending C longs over the net is a Bad Thing. My computers have a
different idea what a long is than yours. Use types with explicit size.
(ints are mostly 32 bit nowadays)

PPS: What is the politically correct way to say little indian? 
"vertically challenged american natives"? or "little endian"? ;-)


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

Date: 23 Sep 1999 12:51:54 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: SSH
Message-Id: <7sd7pa$5mm$1@pegasus.csx.cam.ac.uk>

Kragen Sitaker <kragen@dnaco.net> wrote:
>In article <Pine.GSO.4.10.9909201629550.3836-100000@askja.firedoor.se>,
>Matilda Dahlqvist  <matilda@crt.se> wrote:
>>How can I run 'ssh -L port:host:port -l user host' in the background in a
>>perl script?
>>system() does not work, neither does exec() since I don't want to have to
>>wait for any child process (or for exec, take over the whole program).
>
>system "ssh -L blah blah &" will work.
>
>If you want more control than system with & gives you, you have to fork
>and exec.  (open with a |, or open2, or open3, might serve your needs
>better.)
>
>>I also want to save som kind of pid for that process so I can kill it
>>later.
>
>Oo.  Ouch.

Well, doing your own fork/exec will give you the PID.   Problem is
that it will be the PID of the shell, not of the ssh.    So you
need to get rid of the shell by using the multi-arg form of exec(),
or otherwise.


Mike Guy


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

Date: Thu, 23 Sep 1999 10:34:14 GMT
From: pkey@sghms.ac.uk
Subject: Unix password parser
Message-Id: <37ea0176.762034741@news.dl.ac.uk>

has anyone got any pointers to perl code that can verify a unix
password for a user before it is entered into the passwd file?

i am writing a password changer in perl and am looking for a perl
routine to parse a user entered password for validity to save the
passwd routine from barfing.

any code/pointers to code appreciated.

cheers

paul


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

Date: Thu, 23 Sep 1999 13:49:38 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: Usenet threading code?
Message-Id: <AtoG3.746$OH6.12583@news1.online.no>


Martien Verbruggen <mgjv@comdyn.com.au> wrote in message
news:Q1dG3.52$8B3.3325@nsw.nnrp.telstra.net...
> In article <ruilq6rslg79@news.supernews.com>,
> "Joseph McDonald" <joe@vpop.net> writes:
> > Are there any perl modules for calculating "conversation threads" in
usenet
> > messages (by reference-ID and subject).
> CPAN has a few modules related to NNTP, Net::NNTP and the News::*
> modules. The most likely one to have code like this would be
> News::NNTPClient (although I don't believe there's threading code in
> it. You might be able to use those modules to roll your own, maybe you
> could have a look at the sources for trn or knews or something like
> that. If you roll your own, it would be nice if you made it cooperate
> with these modules, and released it to CPAN :)

None of these have a function to thread articles (at least, I didn't
find it)

A while ago I wrote this piece of code, which will do the threading, but
it doesn't pass 'use strict', and I would probably create the entire
message tree as a hash of hashes today. It's probably obvious that I
didn't have a very good grasp on references when I first made this, so
there is room for quite a lot of improvement here.

(reading old code can be so embarrassing :)

Anyway, I'm just about starting to write yet another Perl-based
newsreader (with Net::NNTP this time), so I will hopefully come up with
something that is a bit cleaner than this :-)

Challenge: which example from the "Perl Cookbook" did I use for
inspiration? (hint: connectReplies())

-----------------8<------------------
#!/local/perl/5.005/bin/perl -w

use News::NNTPClient;
use Tie::IxHash;
use MIME::Words qw(decode_mimewords);

my $nntpserver = "news.online.no"; #insert your own
my $group = "comp.lang.perl.misc";
my $maxmessages = 100;
my $news = new News::NNTPClient("$nntpserver");
my @fields = qw(numb subj from date mesg refr char line xref);

tie my %MESSAGES, "Tie::IxHash";
my %father;
my %Replies;

$news->mode_reader;
listGroup($group);

sub connectReplies {
    while ( my ($k, $v) = each %father ) {
        push( @{ $Replies{$v} }, $k );
    }
}

sub whosYourDaddy {
    return $father{$_[0]} ? whosYourDaddy($father{$_[0]}) : $_[0];
}

sub listGroup {
    my $group = shift;
    print $group, "\n";

    my ($first, $last) = $news->group("$group");
    if (($last - $first) > $maxmessages) {$first = $last - $maxmessages}
    foreach my $header ($news->xover($first, $last)) {
        parseHead($header);
    }

    connectReplies();

    foreach my $msgid (keys %MESSAGES) {
        my $level = 0;
        output(whosYourDaddy($msgid), $level);
    }
}

sub parseHead {
    my $header = shift;
    my %DummyHash;

    chomp $header;

    @DummyHash{@fields} = split (/\t/, decode_mimewords($header));
    my $Message = \%DummyHash;

    if ($Message->{refr}) {
       @{$Message->{refr}} = split(" ", $Message->{refr});
       my @refs = (@{$Message->{refr}}, $Message->{mesg});
        for (my $n=$#refs;$n>0;$n--) {
           unless (exists $father{$refs[$n]}) {
              $father{$refs[$n]} = $refs[$n-1];
           }
       }
    }
    store($Message);
}

sub store {
    $MESSAGES{$_[0]->{mesg}} = $_[0];
    return;
}

sub output {
    my ($msgid, $level) = @_;

    my $Message = $MESSAGES{$msgid};
    my $read = 0;

    if ($Message->{mesg}) {
        print " " x $level,
                   $Message->{subj},
                   ' (', $Message->{from}, ")\n";
        delete $MESSAGES{$Message->{mesg}};
    }
    if (defined @{ $Replies{$msgid} }) {
        $level++;
        foreach my $reply (@{ $Replies{$msgid} }) {output($reply,
$level);}
        $level--;
    }
}
-----------------8<------------------

--
Trond Michelsen





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

Date: Thu, 23 Sep 1999 10:11:13 GMT
From: cmsps@my-deja.com
Subject: Re: Win32::ODBC.pm hangs CGI.pm under Apache
Message-Id: <7scubs$slf$1@nnrp1.deja.com>

In article <t38G3.3449$QJ.198946@typ11.nn.bcandid.com>,
  kragen@dnaco.net (Kragen Sitaker) wrote:
> In article <7sasth$dja$1@nnrp1.deja.com>,  <p.scott@shu.ac.uk> wrote:
> >I am using ODBC to hold data which is displayed on a website.  I get
> >this message with the -w flag:
> >
> >  Use of uninitialized value at C:/Perl/site/lib/Win32/ODBC.pm line 258.
> >
> >and also for lines 257 and 258.
>
> There's probably a bug in your script where you're passing undefined
> values to ODBC.  Maybe there's a bug in ODBC.pm.

Not my script; I've checked for that. Also the problem only appears
when the number of rows exceeds a small threshold.
>
> >If my database has enough rows the
> >error messages cause a perl.exe to run forever.  Without the -w flag
> >everything works.
>
> That's quite astonishing.  That should *never* happen.  Is it possible
> that the -w messages are just making Perl take, say, 100 times as long
> as usual?

No. It can run for an hour without finishing.

Thanks anyway; I'm glad it's not obvious.
> --
> <kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
> Wed Sep 22 1999
> 47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
> <URL:http://www.pobox.com/~kragen/bubble.html>
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 23 Sep 1999 13:03:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Win32::ODBC.pm hangs CGI.pm under Apache
Message-Id: <OypG3.4898$QJ.340321@typ11.nn.bcandid.com>

In article <7scubs$slf$1@nnrp1.deja.com>,  <cmsps@my-deja.com> wrote:
>Thanks anyway; I'm glad it's not obvious.

It might be obvious to someone who knows something about ODBC.pm.  But
that's not me :)

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Thu, 23 Sep 1999 12:55:07 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: You should be admired
Message-Id: <LqpG3.4867$QJ.339219@typ11.nn.bcandid.com>

In article <spamfree-2309991606340001@d6.metropolis.net.au>,
Henry Penninkilampi <spamfree@metropolis.net.au> wrote:
>Tell me, Abigail, how does a petulant child gain respect in life?  I'm
>wondering if you know - you seem to be an authority on the subject.

Abigail won *my* respect by
- posting lots of correct answers
- posting frightening JAPHs
- answering even stupid questions
- standing up for what is right.

You have done none of these.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Wed Sep 22 1999
47 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.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 885
*************************************


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