[21893] in Perl-Users-Digest
Perl-Users Digest, Issue: 4097 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 11 09:06:38 2002
Date: Mon, 11 Nov 2002 06:05:08 -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 Mon, 11 Nov 2002 Volume: 10 Number: 4097
Today's topics:
Difference in behaviour of foreach loop between UNIX an <marnol10@jaguar.com>
Re: Difference in behaviour of foreach loop between UNI <nobull@mail.com>
fetch all the bouncing e-mailaddresses (Leif Wessman)
Re: LWP and https <kbilbee@pictureflipper.com>
Re: LWP and https <bart.lateur@pandora.be>
module for child labour? edgue@web.de
New posters to comp.lang.perl.misc <gbacon@cs.uah.edu>
Re: newbie LWP redirect/cookie question <flavell@mail.cern.ch>
Re: Object in @INC returning Tie::Handles from INC meth <goldbb2@earthlink.net>
Re: Perl CGI Java help <bart.lateur@pandora.be>
Re: Pls recommend me a good Perl programming environmen <techcog@acme.N3T>
Upgrade to Perl 5.6.x ? <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Windows and nonblocking IO edgue@web.de
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Nov 2002 08:42:48 +0000
From: "Mark.Arnold" <marnol10@jaguar.com>
Subject: Difference in behaviour of foreach loop between UNIX and Windows
Message-Id: <3DCF6D88.5C41FDDA@jaguar.com>
I tried using a foreach loop containing PERL's substitution operator to
remove whitespace from the values in a hash. The code is as follows:-
#!/bin/perl -w
%hash = ("o n e" => "t h r e e", "t w o" => "f o u r");
# remove whitespace from values in hash
foreach (values %hash) {
s/\s+//g;
}
# print values in hash
foreach (values %hash) {
print "$_\n";
}
According to my Learning Perl book (and also the man pages), the control
variable ($_) is supposed to be linked (aliased) to the current list
element such that modifying the control variable will actually modify
the current list element.
When I ran this script on a HP Visualise workstation running HP-UX 11.00
(Perl version 5.00503) it did NOT modify the values within the hash as
expected. However, I also tried this script on my Windows 95 PC (latest
ActiveState Perl) and the script DID modify the values within the hash.
Do you know why their is a difference in behaviour between different
hardware and also which is the correct behaviour?
Regards,
Mark Arnold
Engineer, Body CAE (W/1/012)
Jaguar Cars Ltd
Engineering Centre
Abbey Road, Whitley
Coventry, CV3 4LF
Tel: 024 7620 6866
Fax: 024 7620 4953
Email: marnol10@jaguar.com
------------------------------
Date: 11 Nov 2002 12:40:51 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Difference in behaviour of foreach loop between UNIX and Windows
Message-Id: <u9pttc2sa4.fsf@wcl-l.bham.ac.uk>
"Mark.Arnold" <marnol10@jaguar.com> writes:
> foreach (values %hash) {
> s/\s+//g;
> }
> When I ran this script on a HP Visualise workstation running HP-UX 11.00
> (Perl version 5.00503) it did NOT modify the values within the hash as
> expected. However, I also tried this script on my Windows 95 PC (latest
> ActiveState Perl) and the script DID modify the values within the hash.
>
> Do you know why their is a difference in behaviour between different
> hardware
Because you are running Perl 5.5 on one and a more recent Perl on the
other.
> and also which is the correct behaviour?
The more recent one it correct now. In some sense the older is also
correct, in so far as it was the documented behaviour at the time but
IIRC the documentation for values() did say that it wasn't really the
"right thing" and would be fixed in a later release.
> Tel: 024 7620 6866
Surely you mean +44 24 7620 6866 :-)
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 11 Nov 2002 06:03:52 -0800
From: leifwessman@hotmail.com (Leif Wessman)
Subject: fetch all the bouncing e-mailaddresses
Message-Id: <64beeaad.0211110603.188312a0@posting.google.com>
Hi!
I have a file full of e-mailaddresses that bounced when we sent out
our latest newsletter. All the e-mailaddresses are validated before
they was sent out using this regular expression:
if ($email =~ /^[a-zA-Z0-9\-\._]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)
{
print $email." is ok!\n";
}
Now I want to go thru all the bounce-mails and fetch all occurrences
of e-mailadresses like this:
open IN, "<$ARGV[0]" or die "open: $!";
while ($line = <IN>) {
if ($line =~ /^[a-zA-Z0-9\-\._]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/)
{
print $1;
}
}
close IN;
But the problem is that $1 does not contain anything at any point. How
should I write to fetch out the addresses??
Thank you for your help
Leif
------------------------------
Date: Mon, 11 Nov 2002 08:25:45 GMT
From: "Kevin Bilbee" <kbilbee@pictureflipper.com>
Subject: Re: LWP and https
Message-Id: <dQJz9.1104$243.39720985@newssvr14.news.prodigy.com>
Thanks for the responses. I did install Crypt::SSLeay and got the HTTPS to
function.
I ran into another road block in that interland will not install the module
for me.
So I am forced to go with ASPTear component they have installed for use with
ASP.
Thanks again
Kevin Bilbee
------------------------------
Date: Mon, 11 Nov 2002 12:04:21 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: LWP and https
Message-Id: <te6vsuk34akr3r8bkj23n8dbv2c68lu5vn@4ax.com>
Kevin Bilbee wrote:
>I ran into another road block in that interland will not install the module
>for me.
Typical.
Can you "install" it in your own directory? See perlfaq8:
How do I keep my own module/library directory?
How do I add a directory to my include path at runtime?
This appears to be an XS module, so installing it if you don't have
access to a make/compiler is hardly possible. If you do have access to a
very similar system as the target system, same CPU/OS/perl version, then
it just might work compiling the module(s) on your own system and
bringing over the resulting files to the target system. But that is not
for the weak.
--
Bart.
------------------------------
Date: Mon, 11 Nov 2002 10:46:35 +0100
From: edgue@web.de
Subject: module for child labour?
Message-Id: <3DCF7C7B.5030205@web.de>
Hi folks,
just kidding ...
I have to implement a certain scenario and before
doing that I would like to make sure that I dont
start to reprogram something that already exists ...
searching on CPAN didnt help; the misc. Proc:: modules
come close (like Proc::Simple) but not close enough.
Here is what I want to do:
My main program has to fork of a child process.
The child process has to run perl code; it should
communicate with the main process from time to
time ("reading" commands from the main process,
"writing" results / error information to the main
process). The child process would work like this:
while(1) {
... execute the "child work"
... send error information to main process
... check for commands from main process
die if command == EXIT
}
What I really would like is a base class XYZ that
handles all the necessary fork(), pipe(), stuff -
and allows me to subcluss XYZ and implement only methods like
react_to_command()
provide_results()
do_your_job()
that would be called by the framework ... is there
something like that available?
regards,
eg
------------------------------
Date: Mon, 11 Nov 2002 13:07:37 -0000
From: Greg Bacon <gbacon@cs.uah.edu>
Subject: New posters to comp.lang.perl.misc
Message-Id: <usvasp3lr3ad7b@corp.supernews.com>
Following is a summary of articles from new posters spanning a 7 day
period, beginning at 04 Nov 2002 13:08:58 GMT and ending at
11 Nov 2002 12:04:21 GMT.
Notes
=====
- A line in the body of a post is considered to be original if it
does *not* match the regular expression /^\s{0,3}(?:>|:|\S+>|\+\+)/.
- All text after the last cut line (/^-- $/) in the body is
considered to be the author's signature.
- The scanner prefers the Reply-To: header over the From: header
in determining the "real" email address and name.
- Original Content Rating (OCR) is the ratio of the original content
volume to the total body volume.
- Find the News-Scan distribution on the CPAN!
<URL:http://www.perl.com/CPAN/modules/by-module/News/>
- Please send all comments to Greg Bacon <gbacon@cs.uah.edu>.
- Copyright (c) 2002 Greg Bacon.
Verbatim copying and redistribution is permitted without royalty;
alteration is not permitted. Redistribution and/or use for any
commercial purpose is prohibited.
Totals
======
Posters: 95 (35.3% of all posters)
Articles: 163 (20.5% of all articles)
Volume generated: 295.1 kb (19.6% of total volume)
- headers: 133.8 kb (2,602 lines)
- bodies: 159.3 kb (5,393 lines)
- original: 109.2 kb (3,808 lines)
- signatures: 1.9 kb (55 lines)
Original Content Rating: 0.686
Averages
========
Posts per poster: 1.7
median: 1 post
mode: 1 post - 61 posters
s: 1.8 posts
Message size: 1853.9 bytes
- header: 840.7 bytes (16.0 lines)
- body: 1000.6 bytes (33.1 lines)
- original: 685.9 bytes (23.4 lines)
- signature: 11.6 bytes (0.3 lines)
Top 10 Posters by Number of Posts
=================================
(kb) (kb) (kb) (kb)
Posts Volume ( hdr/ body/ orig) Address
----- -------------------------- -------
11 18.4 ( 8.7/ 9.6/ 6.2) "F. Xavier Noria" <fxn@hashref.com>
6 13.5 ( 6.2/ 7.3/ 4.5) "Josh Stedman" <stedman@siam.org>
5 9.8 ( 5.4/ 4.4/ 2.5) John Sellers <newsComments17@sellers.com>
5 8.6 ( 4.5/ 4.1/ 1.7) "George" <sheken@videotron.ca>
4 13.6 ( 2.6/ 11.0/ 6.9) "Joe Moschak" <joe@amrita.net>
4 7.5 ( 4.3/ 3.2/ 1.2) Robin Becker <robin@jessikat.fsnet.co.uk>
4 8.1 ( 3.3/ 3.7/ 2.2) Kirk Is <kirkspam@alienbill.com>
4 6.6 ( 4.0/ 2.3/ 0.9) dmeans-usenet@the-means.net
3 4.1 ( 2.0/ 2.0/ 0.8) Abernathey Family <family2@aracnet.com>
3 4.2 ( 1.9/ 2.3/ 1.7) Hobo <myusenetclient@requiresthis.com>
These posters accounted for 6.2% of all articles.
Top 10 Posters by Volume
========================
(kb) (kb) (kb) (kb)
Volume ( hdr/ body/ orig) Posts Address
-------------------------- ----- -------
18.4 ( 8.7/ 9.6/ 6.2) 11 "F. Xavier Noria" <fxn@hashref.com>
14.9 ( 2.5/ 12.4/ 12.1) 3 Jens Abromeit <j.abromeit@jpberlin.de>
13.6 ( 2.6/ 11.0/ 6.9) 4 "Joe Moschak" <joe@amrita.net>
13.5 ( 6.2/ 7.3/ 4.5) 6 "Josh Stedman" <stedman@siam.org>
9.8 ( 5.4/ 4.4/ 2.5) 5 John Sellers <newsComments17@sellers.com>
8.6 ( 4.5/ 4.1/ 1.7) 5 "George" <sheken@videotron.ca>
8.1 ( 3.3/ 3.7/ 2.2) 4 Kirk Is <kirkspam@alienbill.com>
7.8 ( 2.5/ 5.3/ 3.1) 3 "Rodney Hunter" <rwh2100@hotmail.com>
7.5 ( 4.3/ 3.2/ 1.2) 4 Robin Becker <robin@jessikat.fsnet.co.uk>
6.6 ( 4.0/ 2.3/ 0.9) 4 dmeans-usenet@the-means.net
These posters accounted for 7.2% of the total volume.
Top 10 Posters by OCR (minimum of three posts)
==============================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.973 ( 12.1 / 12.4) 3 Jens Abromeit <j.abromeit@jpberlin.de>
0.762 ( 1.7 / 2.3) 3 Hobo <myusenetclient@requiresthis.com>
0.648 ( 6.2 / 9.6) 11 "F. Xavier Noria" <fxn@hashref.com>
0.623 ( 6.9 / 11.0) 4 "Joe Moschak" <joe@amrita.net>
0.619 ( 4.5 / 7.3) 6 "Josh Stedman" <stedman@siam.org>
0.586 ( 3.1 / 5.3) 3 "Rodney Hunter" <rwh2100@hotmail.com>
0.574 ( 2.2 / 3.7) 4 Kirk Is <kirkspam@alienbill.com>
0.567 ( 2.5 / 4.4) 5 John Sellers <newsComments17@sellers.com>
0.420 ( 1.7 / 4.1) 5 "George" <sheken@videotron.ca>
0.401 ( 1.3 / 3.3) 3 ronwolf <ronwolf@screwthebots.com>
Bottom 10 Posters by OCR (minimum of three posts)
=================================================
(kb) (kb)
OCR orig / body Posts Address
----- -------------- ----- -------
0.586 ( 3.1 / 5.3) 3 "Rodney Hunter" <rwh2100@hotmail.com>
0.574 ( 2.2 / 3.7) 4 Kirk Is <kirkspam@alienbill.com>
0.567 ( 2.5 / 4.4) 5 John Sellers <newsComments17@sellers.com>
0.420 ( 1.7 / 4.1) 5 "George" <sheken@videotron.ca>
0.401 ( 1.3 / 3.3) 3 ronwolf <ronwolf@screwthebots.com>
0.391 ( 1.2 / 3.2) 4 Robin Becker <robin@jessikat.fsnet.co.uk>
0.378 ( 0.9 / 2.3) 4 dmeans-usenet@the-means.net
0.366 ( 0.8 / 2.0) 3 Abernathey Family <family2@aracnet.com>
0.346 ( 1.3 / 3.8) 3 "Craig McNiel" <craig-and-linda@the-mcniels.com>
0.268 ( 1.1 / 4.0) 3 "Robert Robbins" <rrobbins@kolbnetworks.com>
15 posters (15%) had at least three posts.
Top 10 Targets for Crossposts
=============================
Articles Newsgroup
-------- ---------
44 comp.lang.python
43 comp.lang.tcl
43 comp.lang.ruby
10 alt.perl
3 comp.lang.perl
2 comp.lang.perl.modules
1 comp.infosystems.www.misc
Top 10 Crossposters
===================
Articles Address
-------- -------
12 Robin Becker <robin@jessikat.fsnet.co.uk>
6 Simon Cozens <simon@simon-cozens.org>
3 Laotseu <bdesth@free.fr>
3 Paul Boddie <paul@boddie.net>
3 dalke@dalkescientific.com
3 Alan Green <web.mail@lycos.com>
3 =?ISO-8859-1?Q?Jens_Axel_S=F8gaard?= <usenet@jasoegaard.dk>
3 Giuseppe Bilotta <bilotta78@hotpop.com>
1 Dave Steiner <dave.steiner@gmx.net>
1 "Martin Elster" <melster@chello.no>
------------------------------
Date: Mon, 11 Nov 2002 12:11:47 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: newbie LWP redirect/cookie question
Message-Id: <Pine.LNX.4.40.0211111207410.10037-100000@lxplus075.cern.ch>
On Nov 11, Alan Barclay inscribed on the eternal scroll:
> Bryan Castillo <rook_5150@yahoo.com> wrote:
> >(Unless you can submit data in both GET and POST style. I don't know
> >if that can be done or not.)
>
> You can certainly append values to the end of the URL.
Indeed, and CGI.pm explicitly supports such a URL query-string part on
a POST transaction.
> It's still a POST though.
Yes. I'm not entirely sure how well-founded this usage is in
protocol-specification terms, but it's evidently sufficiently well
supported in practice for Stein to consider it worth implementing.
(Speaking for myself, I'd rather avoid using it in anything that I was
implementing, but maybe I'm being over-conservative.)
best regards
--
Such mal ein bisschen nach WEFT und Dynamic Fonts, lies dir
durch was du gefunden hast und komme zu der Erkenntnis, dass
es besser ist, darauf zu verzichten [...] Alles was dem
User nicht nützt, schadet dem Autor. - Steffi in dciwam
------------------------------
Date: Mon, 11 Nov 2002 03:29:47 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Object in @INC returning Tie::Handles from INC method
Message-Id: <3DCF6A7B.5D66BA13@earthlink.net>
Bryan Castillo wrote:
>
> > Well, ordinary open filehandles and tied handles *should* work about
> > the same. Objects derived from IO::Handle are, in fact, ordinary
> > open handles, except that in addition to being able to use the
> > builtin io operators, you can use object-oriented methods on them,
> > too.
> >
> > PerlIO layers are a bit different... however, there should be little
> > enough need for you to concern yourself there, since you generally
> > don't have to deal with PerlIO objects directly; they're hidden
> > inside the internal data of the IO-ref part of the filehandle.
>
> Do you have any idea then, why PerlIO layers work as returned values
> for INC while tied filehandles don't.
I've never seen a PerlIO layer returned from an INC method.
I *have* seen ordinary filehandles (with PerlIO layers pushed onto them
via binmode) returned from an INC method.
Here's an incomplete, untested, pure-perl version of ex::lib::zip :
package ex::lib::zip;
sub import {
my $package = shift;
unshift @INC, map $package->new($_), @_;
}
sub new {
my ($class, $filename) = @_;
bless { filename => $filename }, $class;
}
sub INC {
my ($self, $filename) = @_;
my $zipfile = $self->{filename};
open( my ($fh), "<", $zipfile ) or return;
stat( $fh ) or return;
if( $self->{stat} and
$self->{stat}{s} != -s _ or $self->{stat}{t} != -M _ ) {
%{$self} = { filename => $zipfile };
}
@{ $self->{stat} }{qw(s t)} = ((-s _), (-M _));
my $m;
if( not $m = $self->{member}{$filename} ) {
return if $self->{read_all_headers};
my $seekto = 0;
$seekto = $m->{end} if $m = delete $self->{last_read_member};
READHEADERS: {
seek( $fh, $seekto, 0 ) or return;
unless( $m = $self->read_zip_header( $fh ) ) {
$self->{read_all_headers} = 1;
return;
}
my $name = delete $m->{filename};
$self->{members}{$name} = $m;
$seekto = $m->{end};
redo READHEADERS if $name ne $filename;
$self->{last_read_member} = $m;
}
}
binmode( $fh, ":subfile(start=$$m{start},end=$$m{end})" )
or return;
binmode( $fh, ":gzip(none)" )
or return;
return $fh;
}
Note that it does NOT return the PerlIO objects associated with the
:subfile or :gzip layers -- instead, it returns the $fh object that was
created by open(my($fh), "<", $zipfile).
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 11 Nov 2002 11:50:33 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Perl CGI Java help
Message-Id: <t36vsu8007ijafgb0551hlp0uc4jimq1hr@4ax.com>
Asad wrote:
>Now when users click say sports from main page,
>I run this perl script, that in turn calls a function in Server.java that
>fetches all sports posters from memory, create an HTML page, and send it
>back to perl script which in turn displays this result HTML to user on the
>browser. What I don't understand is how to have PERL script call the Java
>function? I am using PERL, CGI and Java Server btw.
I can imagine doing that in two manners. I don't know which will work.
A) Run the Java program as if it were a CGI script. You can then simply
point the browser to this page with a "Location:" header with an URL.
Or, more hard work, fetch the page with LWP (a library suite to access
remote web pages from within perl). get() from LWP::Simple will do. See
`perldoc lwpcook` (that's the "lwpcook" documentation page as seen with
the "perldoc" comand line utility) .
B) You can run the java fun,ction from the command line? Then use
backticks or qx() (see `perldoc perlop` under qx()) to run an external
program and capture its output. There's also system(), but that doesn't
capture any output.
HTH,
Bart.
------------------------------
Date: Mon, 11 Nov 2002 08:28:39 GMT
From: "techcog@acme.N3T" <techcog@acme.N3T>
Subject: Re: Pls recommend me a good Perl programming environment
Message-Id: <4035827.mAQ0Y1G92f@gryphon>
Peter Wu wrote:
> Can anyone pls recommend me a good Perl programming environment? I
> would like to develop in Perl on Win32 platform and test the program
> on FreeBSD environment.
That depends. I like it to be quiet. Music is okay.
Cold beverages nearby is a plus. Food close at hand is good.
The occasional distraction is okay. Children can be detrimental to
productivity. Recommend non-boring activities for the children if
they must be present. Hope that helps.
>
> Any suggestion is appreciated! Thanks!
>
>
> - Peter
------------------------------
Date: Mon, 11 Nov 2002 11:32:49 -0000
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Upgrade to Perl 5.6.x ?
Message-Id: <aqo4ei$r34$1$8302bc10@news.demon.co.uk>
Derek,
"Derek Thomson" <derek@wedgetail.com> wrote in message
news:3DCF4709.2010203@wedgetail.com...
> You learn a new thing every day. And it's another way to make people
> *finally* trade up to 5.6 :)
Where can I find the most compelling statement of why my project's
Development Manager should give the green light for an upgrade from Perl
5.00404 (!!) to 5.6 (on Solaris 2.6)?
And which 5.6.x is the most stable for reassuring frightened "suits" ?
Thanks,
Clyde
------------------------------
Date: Mon, 11 Nov 2002 13:47:38 +0100
From: edgue@web.de
Subject: Windows and nonblocking IO
Message-Id: <3DCFA6EA.9090804@web.de>
Hi there,
what I read from past postings is that
there is no way to fork() with ActiveState
and later do non-blocking communication between
parent and child process.
Is that still true - or has that changed with
the perl 5.8 beta that is available from
ActiveState?
------------------------------
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 4097
***************************************