[25813] in Perl-Users-Digest
Perl-Users Digest, Issue: 8052 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 5 09:05:27 2005
Date: Thu, 5 May 2005 06:05:09 -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 Thu, 5 May 2005 Volume: 10 Number: 8052
Today's topics:
Re: Different POST encoding format <noreply@gunnar.cc>
Re: Different POST encoding format <wyzelli@yahoo.com>
Re: Different POST encoding format <djb@global.net.mt>
Re: Different POST encoding format <flavell@ph.gla.ac.uk>
Re: Different POST encoding format <djb@global.net.mt>
Re: Different POST encoding format <flavell@ph.gla.ac.uk>
Re: Filling the Perl Stack <guenther.sohler@newlogic.com>
Re: Filling the Perl Stack <tassilo.von.parseval@rwth-aachen.de>
I am confused by this array. <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Re: I am confused by this array. <tassilo.von.parseval@rwth-aachen.de>
Re: regular expression <bckumari@yahoo.com>
Re: regular expression (Greg Bacon)
Re: start_table problem <hackeras@gmail.com>
Re: The Perl Review, Summer 2005 <john@castleamber.com>
Re: The Perl Review, Summer 2005 <john@castleamber.com>
Re: Using pod2html for all modules? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 May 2005 09:33:00 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Different POST encoding format
Message-Id: <3du0raF644hU1@individual.net>
David Joseph Bonnici wrote:
> Hi I was experimenting with perl, on the POST method. I am using
> LWP::UserAgent
>
> $response = $browser->post( $url,
> [ 'first name' => 'John',
> 'last name' => 'Doe',
> 'lastandfirst' => 'John Doe',
> ] );
>
> If I post, the data is sent something like this
> "&first+name=John&last+name=Doe&lastandfirst=John+Doe"
>
> I would like the post to be something enocoded like so (dont ask me why!)
> &first%20name=John&last%20name=Doe&lastandfirst=John&20Doe
Why?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 05 May 2005 07:56:58 GMT
From: "Peter Wyzl" <wyzelli@yahoo.com>
Subject: Re: Different POST encoding format
Message-Id: <elkee.3446$31.1463@news-server.bigpond.net.au>
"David Joseph Bonnici" <djb@global.net.mt> wrote in message
news:d5bvmk$j0d$1@domitilla.aioe.org...
: Hi I was experimenting with perl, on the POST method. I am using
: LWP::UserAgent
:
: $response = $browser->post( $url,
: [ 'first name' => 'John',
: 'last name' => 'Doe',
: 'lastandfirst' => 'John Doe',
: ] );
:
: If I post, the data is sent something like this
: "&first+name=John&last+name=Doe&lastandfirst=John+Doe"
:
: I would like the post to be something enocoded like so (dont ask me why!)
: &first%20name=John&last%20name=Doe&lastandfirst=John&20Doe
:
: How do I do it (or what parameter do I need to modify).
:
: This is sending me crazy.
So url encode your names and values before you post them. But it does beg
the question 'why'. However, I sense an 'X - Y' question.
P
------------------------------
Date: Thu, 5 May 2005 11:07:04 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: Re: Different POST encoding format
Message-Id: <d5cnnr$lco$1@domitilla.aioe.org>
Thanks for coming back to me, both of you. I was in the mean time doing
some reasearch, and I think I found it.
I think that I have to do the escaping on the single pieces of the data
using URI:Escape
for example
....
use URI::Escape;
print uri_escape("David sleeps more 10% than other people do");
....
giving
David%20sleeps%20more%2010%25%20than%20other%20people%20do
I let you know
David
------------------------------
Date: Thu, 5 May 2005 10:00:11 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Different POST encoding format
Message-Id: <Pine.LNX.4.62.0505050957340.6515@ppepc56.ph.gla.ac.uk>
On Thu, 5 May 2005, David Joseph Bonnici wrote:
> Hi I was experimenting with perl, on the POST method. I am using
> LWP::UserAgent
>
> $response = $browser->post( $url,
> [ 'first name' => 'John',
> 'last name' => 'Doe',
> 'lastandfirst' => 'John Doe',
> ] );
>
> If I post, the data is sent something like this
> "&first+name=John&last+name=Doe&lastandfirst=John+Doe"
Check the definition of the form url encoding format. This is the
correct submission.
> I would like the post to be something enocoded like so (dont ask me why!)
> &first%20name=John&last%20name=Doe&lastandfirst=John&20Doe
Stop wanting that. It's not a defined form submission format.
You'd be creating a completely pointless incompatibility with web
interworking specifications.
> This is sending me crazy.
Often happens when one wants the wrong thing. This has nothing to do
with Perl, by the way.
------------------------------
Date: Thu, 5 May 2005 11:49:45 +0200
From: "David Joseph Bonnici" <djb@global.net.mt>
Subject: Re: Different POST encoding format
Message-Id: <d5cq7q$tec$1@domitilla.aioe.org>
Sorry Alan, you are wrong is saying so. I want to do the same thing an
actionscript script is doing in perl. It was not me who has written the
actionscript script, but I have seen this format many times. Pls see
http://www.blooberry.com/indexdot/html/topics/urlencoding.htm I just want
%20's and not + in my post request.
This is what the flash script is sending (captured in Ethereal).
nc=Thu%20May%205%2002%3A51%3A24%20GMT%2B0200%202005&IdChannel=129&Insert%5Fdate=5%2F5%2F2005&key=1HTTP/1.1
100 Continue
Till now I have arrived till here. The only problem remaining is that the
LWP::UserAgent is encoding my % where I want them untouched.
nc=Thu%2520May%25205%252002%252051%252024%2520GMT%252B0200%25202005&IdChannel=127&Insert%2520date=5%252F5%252F2005&key=1HTTP/1.1
100 Continue
I think, that the problem that I have with LWP::UserAgent is that I do not
know how to define the charset to use and/or the encoding to use.
Any help is appreciated.
David
P.S. References (see encoding sections):
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message
news:Pine.LNX.4.62.0505050957340.6515@ppepc56.ph.gla.ac.uk...
> On Thu, 5 May 2005, David Joseph Bonnici wrote:
>
>> Hi I was experimenting with perl, on the POST method. I am using
>> LWP::UserAgent
>>
>> $response = $browser->post( $url,
>> [ 'first name' => 'John',
>> 'last name' => 'Doe',
>> 'lastandfirst' => 'John Doe',
>> ] );
>>
>> If I post, the data is sent something like this
>> "&first+name=John&last+name=Doe&lastandfirst=John+Doe"
>
> Check the definition of the form url encoding format. This is the
> correct submission.
>
>> I would like the post to be something enocoded like so (dont ask me why!)
>> &first%20name=John&last%20name=Doe&lastandfirst=John&20Doe
>
> Stop wanting that. It's not a defined form submission format.
> You'd be creating a completely pointless incompatibility with web
> interworking specifications.
>
>> This is sending me crazy.
>
> Often happens when one wants the wrong thing. This has nothing to do
> with Perl, by the way.
>
------------------------------
Date: Thu, 5 May 2005 12:50:52 +0100
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Different POST encoding format
Message-Id: <Pine.LNX.4.62.0505051237110.18297@ppepc56.ph.gla.ac.uk>
On Thu, 5 May 2005, David Joseph Bonnici wrote:
> Sorry Alan, you are wrong is saying so.
See the authoritative specification,
http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
> I want to do the same thing an actionscript script is doing in perl.
> It was not me who has written the actionscript script, but I have
> seen this format many times.
Nevertheless, it deviates from any forms submission format which is
defined in authoritative specifications, and I stand by the priniciple
that it's a bad idea to propagate such poor engineering.
But this has nothing to do with Perl, so I'm not going to discuss this
in great detail here.
> Pls see
> http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
That's urlencoding, yes, not application/x-www-form-urlencoded
format.
If you were to apply a urlencoding layer to your data first, then your
spaces would turn into %20. Then, application/x-www-form-urlencoded
would have to turn that into %2520 (%25 being the encoded percent
character).
> I just want %20's and not + in my post request.
My advice continues to be that you should stop wanting that.
> This is what the flash script is sending (captured in Ethereal).
>
> nc=Thu%20May%205%2002%3A51%3A24%20GMT%2B0200%202005&IdChannel=129&Insert%5Fdate=5%2F5%2F2005&key=1HTTP/1.1
But this conforms to no published interworking specification; I don't
see any advantage in deviating from known specifications.
> Till now I have arrived till here. The only problem remaining is that the
> LWP::UserAgent is encoding my % where I want them untouched.
Of course, it's designed to do its proper job, not the piece of
misconceived "design" which you're trying to emulate.
> I think, that the problem that I have with LWP::UserAgent is that I do not
> know how to define the charset to use and/or the encoding to use.
That's got nothing to do with your stated problem, though.
good luck
------------------------------
Date: Thu, 05 May 2005 10:33:53 +0200
From: Guenther Sohler <guenther.sohler@newlogic.com>
Subject: Re: Filling the Perl Stack
Message-Id: <pan.2005.05.05.08.33.53.55548@newlogic.com>
Hallo Tassilo,
thank you for your answer. It works perfect. You just forgor to put one
pair of paranthesis.
Using perl my program becomes very powerful!
If you want, I can send you a screenshot of a layout generated by perl
code :)
------------------------------
Date: Thu, 5 May 2005 12:43:04 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: Filling the Perl Stack
Message-Id: <slrnd7ju5o.3mg.tassilo.von.parseval@localhost.localdomain>
Also sprach Guenther Sohler:
> Hallo Tassilo,
>
> thank you for your answer. It works perfect. You just forgor to put one
> pair of paranthesis.
> Using perl my program becomes very powerful!
> If you want, I can send you a screenshot of a layout generated by perl
> code :)
Maybe you can put it into some publicly available spot on the internet
so that everyone here can see it?
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Thu, 05 May 2005 00:12:07 -0600
From: Spin <cNaOlSePbA@MvPeLtEsAtSaEr.com>
Subject: I am confused by this array.
Message-Id: <117je9nkhovb645@corp.supernews.com>
I am somewhat new to Perl still and am having difficulty understanding
the hash/array thing with my PHP background. I read the array/hash docs
and checked the FAQ.
This is my script:
#!/usr/bin/perl -w
use strict;
use XML::Simple;
my $xml = XMLin($ARGV[0]);
use Data::Dumper;
my @accession_header =
$xml->{'Accession'}->{'AccessionHeader'}->{'Accession-ID'};
my $i;
print "for loop\n";
for ($i = 0; $i < 3; $i++) {
print $i.". ".Dumper($accession_header[0][$i]);
}
print "foreach loop\n";
my $count = 0;
foreach ($accession_header[0]) {
print $count.". ".Dumper($_)."\n";
$count++;
}
------
This gives me the following output:
for loop
0. $VAR1 = {
'ID' => '31750',
'Type' => 'Clinic-AccID'
};
1. $VAR1 = {
'ID' => '7019',
'Type' => 'Chart-ID'
};
2. $VAR1 = {
'ID' => 'DEMO13626282',
'Type' => 'Lab-AccID'
};
foreach loop
0. $VAR1 = [
{
'ID' => '31750',
'Type' => 'Clinic-AccID'
},
{
'ID' => '7019',
'Type' => 'Chart-ID'
},
{
'ID' => 'DEMO13626282',
'Type' => 'Lab-AccID'
}
];
Now I know from the foreach loop that I have three items in my
@accession_header[0] array. The problem is that I have to put "3" in my
for loop as a maximum iteration count where I should put
$#accession_header[0]. But $#accession_header[0] gives me a syntax error
"syntax error at ./zoasis.pl line 51, near "$#accession_header["
Execution of ./zoasis.pl aborted due to compilation errors."
And I can't count on it being 3 items all the time. How do I find out
how many items to loop for?
TIA
Caleb
------------------------------
Date: Thu, 5 May 2005 08:55:30 +0200
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: I am confused by this array.
Message-Id: <slrnd7jgr2.p2.tassilo.von.parseval@localhost.localdomain>
Also sprach Spin:
> I am somewhat new to Perl still and am having difficulty understanding
> the hash/array thing with my PHP background. I read the array/hash docs
> and checked the FAQ.
>
> This is my script:
>
> #!/usr/bin/perl -w
>
> use strict;
> use XML::Simple;
>
> my $xml = XMLin($ARGV[0]);
>
> use Data::Dumper;
>
> my @accession_header =
> $xml->{'Accession'}->{'AccessionHeader'}->{'Accession-ID'};
>
> my $i;
> print "for loop\n";
> for ($i = 0; $i < 3; $i++) {
> print $i.". ".Dumper($accession_header[0][$i]);
> }
> print "foreach loop\n";
> my $count = 0;
> foreach ($accession_header[0]) {
> print $count.". ".Dumper($_)."\n";
> $count++;
> }
>
> ------
> This gives me the following output:
>
> for loop
> 0. $VAR1 = {
> 'ID' => '31750',
> 'Type' => 'Clinic-AccID'
> };
> 1. $VAR1 = {
> 'ID' => '7019',
> 'Type' => 'Chart-ID'
> };
> 2. $VAR1 = {
> 'ID' => 'DEMO13626282',
> 'Type' => 'Lab-AccID'
> };
> foreach loop
> 0. $VAR1 = [
> {
> 'ID' => '31750',
> 'Type' => 'Clinic-AccID'
> },
> {
> 'ID' => '7019',
> 'Type' => 'Chart-ID'
> },
> {
> 'ID' => 'DEMO13626282',
> 'Type' => 'Lab-AccID'
> }
> ];
>
> Now I know from the foreach loop that I have three items in my
> @accession_header[0] array. The problem is that I have to put "3" in my
> for loop as a maximum iteration count where I should put
> $#accession_header[0].
$#array gives you the highest index of @array. If you want to use this
as the maximum iteration count, then the loop would have to look thusly:
for ($i = 0; $i <= $#array; $i++)
Note the '<='. The number of elements of an array is one higher than the
maximum index. You get the number of elements by evaluating the array in
scalar context:
for ($i = 0; $i < @array; $i++)
Here, the '<' is correct.
But you shouldn't be using these C-style for-loops anyway. See below.
> But $#accession_header[0] gives me a syntax error
> "syntax error at ./zoasis.pl line 51, near "$#accession_header["
> Execution of ./zoasis.pl aborted due to compilation errors."
$accession_header[0] contains a reference to an array. In order to get
the hightest index, you have to do:
$#{ $accession_header[0] }
Having a PHP background, you may find Perl references tricky to deal
with. However, there's a couple of useful manpages:
perldoc perlreftut
perldoc perlref
perldoc perllol
perldoc perldsc
> And I can't count on it being 3 items all the time. How do I find out
> how many items to loop for?
Most of the time you don't. You simply iterate over all the elements of
the array, but not over the indices:
for my $elem (@{ $accession_header[0] }) {
print Dumper $elem;
}
This can be used in a similar fashion if you need the indices:
for my $i (0 .. $#{ $accession_header[0] }) {
print "$i . ", Dumper $accession_header[0]->[$i], "\n";
}
Finally, you're using strictures in your script which is fine. However,
Perl makes narrow scoping very easy so you can just declare variables
where you need them first, and not before:
for (my $i = 0; $i < 10; i += 2) {
...
}
This will restrict the visibility of $i to the for-declaration and
-loop.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Thu, 05 May 2005 04:19:48 -0400
From: "kums" <bckumari@yahoo.com>
Subject: Re: regular expression
Message-Id: <cd32373f3b4711f00882ae025c196777@localhost.talkaboutprogramming.com>
hai,
Thanks. it is working
can u explain the following line .
1 while s/^([-+]?\d+)(\d{2})/$1,$2/;
------------------------------
Date: Thu, 05 May 2005 12:54:25 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: regular expression
Message-Id: <117k5s1r8rb5r47@corp.supernews.com>
kums <bckumari@yahoo.com> wrote:
: Thanks. it is working
: can u explain the following line .
:
: 1 while s/^([-+]?\d+)(\d{2})/$1,$2/;
See <URL:http://faq.perl.org/perlfaq5.html#How_can_I_output_my_>
Hope this helps,
Greg
--
After getting his fill of life in the big cities -- Washington and L.A.,
Kauffman returns to Batavia to make a life. He runs into a formerly famous
rock star who has returned home to flip pizzas. Kauffman's reaction: "Would
you like mushrooms on your mortification?" -- James Ostrowski
------------------------------
Date: Thu, 05 May 2005 12:29:17 +0300
From: Nikos <hackeras@gmail.com>
Subject: Re: start_table problem
Message-Id: <d5cp1b$2m4$1@nic.grnet.gr>
Chris Mattern wrote:
> axel@white-eagle.co.uk wrote:
>
>
>>An interesting philosophical question. Nikos claims to be Greek, but I
>>suspect he has not read many Socratic dialogues. Ah well, people can
>>always learn, I Hope.
Many not, some yes.
> Well, Socrates also claimed he knew nothing. But I think that was not
> quite the same thing...
Socrated used to said a lot: "Εν οίδα, ό,τι ουδέν οίδα!"
Transation: "One thing i know for sure, that i dont know anything!"
--
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."
------------------------------
Date: 5 May 2005 06:24:06 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: The Perl Review, Summer 2005
Message-Id: <Xns964DDE8EF293castleamber@130.133.1.4>
Gregory Toomey wrote:
> John Bokma wrote:
>
>>
>> I just wonder how many people will perceive this as a commercial
>> message...
>
> Yes, advertising yourself as a programmer for hire is a commercial
> message.
If you consider a signature advertising, do yourself, and maybe the entire
Usenet community a favour, read the netiquette carefully.
clueless n00b.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 May 2005 06:30:40 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: The Perl Review, Summer 2005
Message-Id: <Xns964DF047DA87castleamber@130.133.1.4>
Gregory Toomey wrote:
> But then, most spammers dont draw attention to themselves.
I wonder how happy bigpond.com is with you using nospam@ as a drop box.
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: 5 May 2005 09:42:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Using pod2html for all modules?
Message-Id: <d5cpqa$pvi$1@mamenchi.zrz.TU-Berlin.DE>
John Smith <jsmith@nowhere.com> wrote in comp.lang.perl.misc:
> Hi,
>
> Does anyone know of a simple way (maybe with pod2html?) to generate cross-
> regferenced HTML pages for all the perl modules on my machine?
Apply pod2html to all of them. There won't be more cross-references than
the pod authors put into them, probably not very many.
Anno
------------------------------
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 V10 Issue 8052
***************************************