[21765] in Perl-Users-Digest
Perl-Users Digest, Issue: 3969 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 14 18:05:44 2002
Date: Mon, 14 Oct 2002 15: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)
Perl-Users Digest Mon, 14 Oct 2002 Volume: 10 Number: 3969
Today's topics:
Re: Code explaination <THANKS> <uxrules@netscape.net>
Re: Code explaination <s_grazzini@hotmail.com>
Re: Convert Perl script to C program (and Why was this <jurgenex@hotmail.com>
Re: E-mail reader questions Oct. 13, 2002 <mining_pioneer@hotmail.com>
Re: E-mail reader questions Oct. 13, 2002 <edgrsprj@ix.netcom.com>
Re: Extensible event loop architecture <nospam-abuse@ilyaz.org>
Re: How can I display different charsets with Perl unde <goldbb2@earthlink.net>
Re: HTTP Command help....? <flavell@mail.cern.ch>
Re: HTTP Command help....? <asimmons@mitre.org>
Re: HTTP Upload From PERL to Web Page <3b533a81314e4@heavyk.org>
Re: Multiple Pings/Second <goldbb2@earthlink.net>
Re: Read a single character from STDIN (W98) <bongie@gmx.net>
Regular Expression Hell (RealServer Log) (Joe Follansbee)
Re: Regular Expression Hell (RealServer Log) <ak@freeshell.org.REMOVE>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 14 Oct 2002 13:42:01 -0600
From: JamieBohr <uxrules@netscape.net>
Subject: Re: Code explaination <THANKS>
Message-Id: <3DAB1E09.9000700@netscape.net>
Thanks to all who replied, it was a lot of help.
- Jamie
JamieBohr wrote:
> Can some one explain what/how this code works:
>
> print $==()=<>, "\n";
>
> I know this will count the input lines, but how? I know what <> does
> have not a clue about the rest. Any help would be appreciated.
>
> - Jamie
>
------------------------------
Date: Mon, 14 Oct 2002 19:56:23 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Code explaination
Message-Id: <HjFq9.10621$Up6.2047938@twister.nyc.rr.com>
Dave Arnold <dave@caledvwlch.coma.psuk> wrote:
> In message <3DAAFCB5.3080104@netscape.net>
> JamieBohr <uxrules@netscape.net> wrote:
>
>> Can some one explain what/how this code works:
>>
>> print $==()=<>, "\n";
>>
...
> $= = - assigns the list to a scalar, hence assigning the number of entries
>
> I'm not sure why assigning to an empty list like this works, I assume that
> the Perl compiler optimizes the middle assignment out.
This is wrong.
Japhy has the correct explanation earlier in the thread,
so I won't repeat it here... The important point is that
the OP's code reduces to:
$scalar = LIST_ASSIGNMENT_EXPR;
Which is not the same as "assigning a list to a scalar".
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: Mon, 14 Oct 2002 11:35:07 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Convert Perl script to C program (and Why was this group's name changed?)
Message-Id: <3dab0e5e$1@news.microsoft.com>
Fredo wrote:
> Stop denying
> the *fact* that there is a problem. Only then will this group be free
> of the hate and torment that has beheld it the last serveral years.
Quite right, there is a serious problem here: people are not educated by
their ISPs how to behave in Usenet, ignoring FAQs, ignoring Nettiquette, not
reading for 2 weeks before actively participating, posting off topic, .....
It's like someone coming into an opera hall and first thing those 'newbies'
do is bumping up their boom boxes. No idea why, maybe because they were used
to do so at their family picnic. But do you really expect people to go easy
on those idiots which ignore the basic rules of social behaviour?
Oh, btw, does any of this have anything to do with Perl?
jue
------------------------------
Date: Mon, 14 Oct 2002 22:16:02 +0200
From: "\(#} jpturcaud" <mining_pioneer@hotmail.com>
Subject: Re: E-mail reader questions Oct. 13, 2002
Message-Id: <aof8rf$otj$1@news2adm.tiscali.fr>
Dear EDG,
Have you tried these links :
Perl Mongers - [ Traduire cette page ]
Perl Mongers - The Perl advocacy people. ... Perl 5.8.0 released! "After
CPAN - [ Traduire cette page ]
Comprehensive Perl Archive Network. Welcome to
ActiveState - Applied Open Source - [ Traduire cette page ]
... ActiveState, Perl, Python, PHP, Tcl, XSLT. ... Products. ASPN Perl. ASPN
Tcl. Komodo.
Perl Dev Kit. PerlEx. PerlMx. Tcl Dev Kit. Visual Perl. Visual Python.
Visual XSLT.
perl.com: What's New in Perlland? [Jul. 25, 1999] - [ Traduire cette page ]
... Why we don't need or want a ?? operator in Perl [31 July 1999] This
FAQ-style
use Perl: All the Perl that's Practical to Extract and Report - [ Traduire
cette page ]
use Perl, search use Perl. ... The Perl Journal Lives! posted by gnat on
--
Jean-Paul Turcaud
Hydro & Mining Prospector
Pioneer Of Australian Mining
Discoverer of Telfer; Kintyre & Nifty Mines in The Great Sandy Desert.
Discoverer of the South Atlantic Submarine Gold Placers
_ 40 Millions Tons estimate _
Founder of The TRUE GEOLOGY
* The Greatest Australian Mining Covered Up Swindle Of The 20th Century
http://membres.lycos.fr/jpturcaud/
* The True Geology ( previously Refutation of the Horrid Geological Myths )
http://membres.lycos.fr/xxx/ ( Not available )
~~Ignorance Is The Cosmic Sin, The One Never Forgiven ! ~~
"E.D.G." <edgrsprj@ix.netcom.com> a écrit dans le message de news:
aoc3sa$kac$1@slb6.atl.mindspring.net...
> From: E.D.G. Professional Analyst edgrsprj@ix.netcom.com
> Web Sites: http://www.freewebz.com/eq-forecasting/index.html
> http://home.netcom.com/~edgrsprj/index.html
> Date: October 13, 2002
>"snip"
------------------------------
Date: Mon, 14 Oct 2002 16:45:14 -0500
From: "E.D.G." <edgrsprj@ix.netcom.com>
Subject: Re: E-mail reader questions Oct. 13, 2002
Message-Id: <aofdum$8to$1@slb2.atl.mindspring.net>
October 14, 2002
Thanks for the information. I checked several computer program Web sites
but not the ones you mentioned. At the moment I am talking with technical
people at a particular Internet server to see what type CGI programs will
run at the Web sites they host.
E.D.G.
"(#} jpturcaud" <mining_pioneer@hotmail.com> wrote in message
news:aof8rf$otj$1@news2adm.tiscali.fr...
>
> Dear EDG,
> Have you tried these links :
> Perl Mongers - [ Traduire cette page ]
> Perl Mongers - The Perl advocacy people. ... Perl 5.8.0 released! "After
>
>
> CPAN - [ Traduire cette page ]
> Comprehensive Perl Archive Network. Welcome to
>
>
> ActiveState - Applied Open Source - [ Traduire cette page ]
> ... ActiveState, Perl, Python, PHP, Tcl, XSLT. ... Products. ASPN Perl.
ASPN
> Tcl. Komodo.
> Perl Dev Kit. PerlEx. PerlMx. Tcl Dev Kit. Visual Perl. Visual Python.
> Visual XSLT.
>
>
> perl.com: What's New in Perlland? [Jul. 25, 1999] - [ Traduire cette
page ]
> ... Why we don't need or want a ?? operator in Perl [31 July 1999] This
> FAQ-style
>
>
> use Perl: All the Perl that's Practical to Extract and Report - [ Traduire
> cette page ]
> use Perl, search use Perl. ... The Perl Journal Lives! posted by gnat on
>
------------------------------
Date: Mon, 14 Oct 2002 20:00:10 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Extensible event loop architecture
Message-Id: <aof7oa$29jn$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Rocco Caputo
<troc@netrus.net>], who wrote in article <slrnaqhftq.8ma.troc@eyrie.homenet>:
> > But what makes them *events*?
> Your extension makes them events...
[a lot of other irrelevant stuff removed]
Here is what Benjamin explained in a private email: this question was
about flock(). flock() may block [this is what I was missing!]. So
in an event-loop architecture one needs to split flock() into two
parts: flock_start(), and run_when_flock_ends(CODE). This way a
completion of flock() becomes an event. Same with other blocking calls.
[Of course I needed this myself some time ago, but completely forgot. Sigh...]
Hope this helps,
Ilya
------------------------------
Date: Mon, 14 Oct 2002 17:12:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How can I display different charsets with Perl under Windows
Message-Id: <3DAB332C.67ED76F8@earthlink.net>
Christian Kappler wrote:
[snip]
Perl does not understand charsets and fonts.
Perl only understands encodings.
With perl5.8, you can do either:
open( FILEHANDLE, "<:encoding(cp1252)", "file.txt" )
or die $!;
or:
open( FILEHANDLE, "<", "file.txt" ) or die $!;
binmode( FILEHANDLE, ":encoding(cp1252)" );
So that when perl reads from a file in some encoding or other, it
translates it into perl's internal character format (which happens to be
utf8, but you don't need to know that).
Similar commands allow you to write to files in such a way that perl
will translate from it's internal character format into some external
encoding.
Your "richedit control" undoubtably expects that data be passed to it in
some specific encoding. To translate from perl's internal character
format to a different encoding, without writing the result to a file,
you would do:
use Encoding qw(encode);
my $windows_encoded_octets = encode( "cp1252",
$string_in_perls_internal_format );
Find the documentation for this "richedit" thingy (I've no clue what it
is, and don't particularly care), and learn precisely what encoding it
expects it's input data to be in. Then, use the Encode module (or the
":encoding(...)" PerlIO layer, if richedit wants a file, not a string)
to convert your data into that format.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 14 Oct 2002 20:39:31 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: HTTP Command help....?
Message-Id: <Pine.LNX.4.40.0210142009200.27277-100000@lxplus075.cern.ch>
On Oct 14, Aaron Simmons top-posted with fullquote (always a danger
sign):
> I am not exactly sure what you are asking for?
I posted a reply 3 days ago. It might or might not have been the
right answer, but if you didn't see it, there's probably something
wrong with your news feed, and you're liable to stumble into this kind
of morass again.
> I think you are asking how
> can you do a server-side redirect from CGI script for example.
You could be right in that, though to be honest I don't think so: the
questioner appeared to be aware of the Location: response - and was
asking how to do something (it wasn't quite clear what, unfortunately)
withOUT using it.
> You can use
> CGI.pm's redirect method
> (http://stein.cshl.org/WWW/software/CGI/cgi_docs.html -- search for
> redirect)
That would be a good answer, if indeed it was what was wanted.
> The HTTP syntax is as follows:
But a CGI script (if using parsed headers) doesn't use HTTP syntax, it
uses CGI syntax - the similarity is intentional, but the differences
can be significant.
> HTTP/1.0 302 Moved Temporarily
Not from a parsed-headers script, no.
> Location: $url
OK
> URI: <$url>
That is a piece of ancient history, which does no harm but isn't
actually needed (if it ever was). The traditional NCSA CGI
specifiation says just the same as the latest CGI RFC draft on this
point: redirection is done with a "Location:" response.
> - I believe the "HTTP/1.0 302 Moved Temporarily" is optional
For a parsed-headers script it is wrong, and will cause problems with
some servers. Others are more tolerant.
Non-parsed-headers scripts call for a complete and accurate HTTP
response, on the other hand.
> (I only use it for IIS)
(whose support for the CGI specification seems to be somewhat
eccentric. Fortunately, CGI.pm knows how to tame it, hence the
recommendation to newcomers NOT to try knitting their own response as
you appear to be trying to do.)
> - I believe just "URI: <$url>\n\n" is also sometimes acceptable--it depends
> on the web server
The CGI specification is an open interworking specification: it's not
supposed to put core functionality at the whim of a server
implementer.
The CGI RFC draft tells you what it considers is still open to the
server implementer. It might be wise to make oneself familiar with
the published specification before offering answers to questions about
it.
It may well be that some servers are also willing to handle
non-standard responses, but I'd counsel against putting any reliance
on that when there is a specified correct way to do it.
The Perl FAQ part 9 has some useful pointers to CGI topics, I reckon:
http://www.perldoc.com/perl5.8.0/pod/perlfaq9.html
(I guess I have to declare a bit of an interest...)
good luck. (The regulars are welcome to berate me if I've dealt with
this too harshly, but I don't really like leaving messes like this
hanging around to confuse others.)
[TOFU environmentally recycled]
------------------------------
Date: Mon, 14 Oct 2002 15:20:22 -0400
From: "Aaron Simmons" <asimmons@mitre.org>
Subject: Re: HTTP Command help....?
Message-Id: <aof5cl$o9n$1@newslocal.mitre.org>
How is it exactly that someone who is not the original poster can reply to
my simple trying-to-be-helpful response with such garbage? How do you know
that my reply, as messing as you think it is, didn't help Bill [AB] out? I
have a subroutine named PrintRedir($url) that I have used since 9/18/96 that
does exactly what I believe the original poster was asking for. All I did
was explain the logic of that routine. If it's not what he wanted, let him
respond saying so, and someone else may be able to help him. But as for
your reply, why did you even waste your time?!? Are you of the belief that
you need to be qualified or certified in order to have the privilege to
reply to Perl questions? Get off your high horse!
--
Aaron Simmons
G066-Software Systems Eng, Lead
(703) 883-3394
AaronSimm1 (AIM)
"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0210142009200.27277-100000@lxplus075.cern.ch...
> On Oct 14, Aaron Simmons top-posted with fullquote (always a danger
> sign):
>
> > I am not exactly sure what you are asking for?
>
> I posted a reply 3 days ago. It might or might not have been the
> right answer, but if you didn't see it, there's probably something
> wrong with your news feed, and you're liable to stumble into this kind
> of morass again.
>
> > I think you are asking how
> > can you do a server-side redirect from CGI script for example.
>
> You could be right in that, though to be honest I don't think so: the
> questioner appeared to be aware of the Location: response - and was
> asking how to do something (it wasn't quite clear what, unfortunately)
> withOUT using it.
>
> > You can use
> > CGI.pm's redirect method
> > (http://stein.cshl.org/WWW/software/CGI/cgi_docs.html -- search for
> > redirect)
>
> That would be a good answer, if indeed it was what was wanted.
>
> > The HTTP syntax is as follows:
>
> But a CGI script (if using parsed headers) doesn't use HTTP syntax, it
> uses CGI syntax - the similarity is intentional, but the differences
> can be significant.
>
> > HTTP/1.0 302 Moved Temporarily
>
> Not from a parsed-headers script, no.
>
> > Location: $url
>
> OK
>
> > URI: <$url>
>
> That is a piece of ancient history, which does no harm but isn't
> actually needed (if it ever was). The traditional NCSA CGI
> specifiation says just the same as the latest CGI RFC draft on this
> point: redirection is done with a "Location:" response.
>
> > - I believe the "HTTP/1.0 302 Moved Temporarily" is optional
>
> For a parsed-headers script it is wrong, and will cause problems with
> some servers. Others are more tolerant.
>
> Non-parsed-headers scripts call for a complete and accurate HTTP
> response, on the other hand.
>
> > (I only use it for IIS)
>
> (whose support for the CGI specification seems to be somewhat
> eccentric. Fortunately, CGI.pm knows how to tame it, hence the
> recommendation to newcomers NOT to try knitting their own response as
> you appear to be trying to do.)
>
> > - I believe just "URI: <$url>\n\n" is also sometimes acceptable--it
depends
> > on the web server
>
> The CGI specification is an open interworking specification: it's not
> supposed to put core functionality at the whim of a server
> implementer.
>
> The CGI RFC draft tells you what it considers is still open to the
> server implementer. It might be wise to make oneself familiar with
> the published specification before offering answers to questions about
> it.
>
> It may well be that some servers are also willing to handle
> non-standard responses, but I'd counsel against putting any reliance
> on that when there is a specified correct way to do it.
>
> The Perl FAQ part 9 has some useful pointers to CGI topics, I reckon:
> http://www.perldoc.com/perl5.8.0/pod/perlfaq9.html
> (I guess I have to declare a bit of an interest...)
>
> good luck. (The regulars are welcome to berate me if I've dealt with
> this too harshly, but I don't really like leaving messes like this
> hanging around to confuse others.)
>
>
> [TOFU environmentally recycled]
>
>
------------------------------
Date: Mon, 14 Oct 2002 16:03:10 -0500
From: Keith Resar <3b533a81314e4@heavyk.org>
Subject: Re: HTTP Upload From PERL to Web Page
Message-Id: <RN2dncY4c_aTrDagXTWc3w@News.GigaNews.Com>
After a long day of searching, this is what works.
use HTTP::Request::Common;
$ua = LWP::UserAgent->new;
$ua->request(
POST 'http://somewebsite/somescript.cgi',
Content_Type => 'form-data',
Content => [
somefileuploadfield => ["somefilename"],
someotherformfield => 'somevalue',
]
);
Thanks to Mr. Jansson for the pointer.
Keith Resar.
In article <DF-dneibl_udZTegXTWc3A@News.GigaNews.Com>, Keith Resar wrote:
>
> Can anyone point me towards information on how to upload a file from a
> PERL script to a web page that has an <input type=file> form element?
>
> Keith Resar.
>
--
------------------------------
Date: Mon, 14 Oct 2002 16:08:54 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multiple Pings/Second
Message-Id: <3DAB2456.C2EB3825@earthlink.net>
Kevin Vaughn wrote:
>
> I ran smackdab's code, and I got the same error. I used $^E like you said
> (never used it before) and I got this:
>
> "Error in recv: Unknown error #0x2726 (lookup 0x13D) at C:\scripts\ping.pl
> line 53."
The hexadecimal number 0x2726 is equal to the decimal number 10022.
Doing a search:
http://www.google.com/search?q=windows-socket-error+10022
Indicates that this is WSAEINVAL:
" Invalid argument.
Some invalid argument was supplied (for example, specifying an
invalid level to the setsockopt function). In some instances, it
also refers to the current state of the socket – for instance,
calling accept on a socket that is not listening."
At this point, I cannot help you further, because I don't see *why* you
would be getting this error when calling recv. I would suggest you find
a microsoft windows newsgroup, and ask for help there.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 14 Oct 2002 20:46:29 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Read a single character from STDIN (W98)
Message-Id: <1120500.VdRynOXAR1@nyoga.dubu.de>
Nemo Oudeheis wrote:
> I am using ActivePerl on a Win98 system. I would like to read a
> single character from STDIN to get the reply from a (Y/N) question,
> without having to terminate the line with by hitting <ENTER>, as is
> the default with getc and read.
This is a FAQ.
See perldoc -q "single character".
Ciao,
Harald
--
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
If one synchronized swimmer drowns, do the rest have to drown too?
------------------------------
Date: 14 Oct 2002 14:23:58 -0700
From: jfollansbee@speakeasy.net (Joe Follansbee)
Subject: Regular Expression Hell (RealServer Log)
Message-Id: <38076b12.0210141323.7dc2bb83@posting.google.com>
Hi,
I'm trying to put entries from a RealServer log into a database and I
need to pull data from the log entries. I'm tearing me hair out to
build a regex that will match the "client info" entry. The regex has
to be able to find these two typical entries:
[Mozilla/4.0 (compatible;MSIE 5.01;Windows NT 5.0;AT&T CSM6.0)]
[WinNT_5.0_6.0.10.505_play32_RN9GPD_en-US_686_axembed]
Please help!
Thank you.
Joe Follansbee
------------------------------
Date: Mon, 14 Oct 2002 21:31:51 -0000
From: Andreas =?iso-8859-1?Q?K=E4h=E4ri?= <ak@freeshell.org.REMOVE>
Subject: Re: Regular Expression Hell (RealServer Log)
Message-Id: <slrnaqmdu2.bua.ak@otaku.freeshell.org>
Submitted by "Joe Follansbee" to comp.lang.perl.misc:
> Hi,
>
> I'm trying to put entries from a RealServer log into a database and I
> need to pull data from the log entries. I'm tearing me hair out to
> build a regex that will match the "client info" entry. The regex has
> to be able to find these two typical entries:
>
> [Mozilla/4.0 (compatible;MSIE 5.01;Windows NT 5.0;AT&T CSM6.0)]
> [WinNT_5.0_6.0.10.505_play32_RN9GPD_en-US_686_axembed]
>
> Please help!
>
> Thank you.
>
> Joe Follansbee
You will have to tell us what entries it should not pull out as
well.
--
Andreas Kähäri @ New Zealand +------ Have a Unix: netbsd.org
-----------------------------+------ This post ends with :wq
------------------------------
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 3969
***************************************