[29932] in Perl-Users-Digest
Perl-Users Digest, Issue: 1175 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 7 00:09:45 2008
Date: Sun, 6 Jan 2008 21:09:06 -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 Sun, 6 Jan 2008 Volume: 11 Number: 1175
Today's topics:
Create a script to manipulate a flat file <mrbungle50@hotmail.com>
Re: minicpan, CPAN/CPANPLUS and autobundles on linux <doom@kzsu.stanford.edu>
Re: Print a perl array to html textarea ... <motic.mail@gmail.com>
Re: Print a perl array to html textarea ... <jurgenex@hotmail.com>
Re: Print a perl array to html textarea ... <sbryce@scottbryce.com>
Re: Print a perl array to html textarea ... <uri@stemsystems.com>
Search regular expression with search for hex values in (Peter Hanke)
Re: Search regular expression with search for hex value <rvtol+news@isolution.nl>
Re: WWW::Mechanize : Is immediate caching of images pos hikari.no.hohenheim@gmail.com
Re: WWW::Mechanize : Is immediate caching of images pos <ben@morrow.me.uk>
Re: WWW::Mechanize : Is immediate caching of images pos <joost@zeekat.nl>
Re: WWW::Mechanize : Is immediate caching of images pos hikari.no.hohenheim@gmail.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 6 Jan 2008 19:45:00 -0800 (PST)
From: mrbungle50 <mrbungle50@hotmail.com>
Subject: Create a script to manipulate a flat file
Message-Id: <9e5b06f6-7bae-401b-9680-4adeaa70af5a@21g2000hsj.googlegroups.com>
Hello all,
I have a question about designing a script that does two things. My
skills in script writing are limited so will need you to be patient
please.
I have a file downloaded to a server (Linux box) that contains set
length data in it. for example name, phone_number, address, zip_code,
balance
this file is what goes into an application whcih then translates the
data and uses it according to certain criteria set in the data in the
file.
What I need to achieve is.....
I want to read the zip_code on one row and if the zip_code is
(example)9000 I want to add a zone_code of (example)09 to the
beginning of the phone_number section.
The file is not delimited by commas etc, but mainly by character
spacing.
So if a row in the flat file reads the following:
987412wallabywayPerthWA9077000094730308JohnCitizen
that would be account number, house No, street, suburb/city, state,
zip code, leading 3 zeros, phone number, first name, last name.
I want to check if the zip code is 9XXX then remove the last 2 leading
zeros and insert the zone code in it's place.
The reason for this to put it in context is in Australia we have
telephone area codes that span different states. eg: 08 can be for
south Australia and the northern territory. But they are on different
time zones (only an hour) but if the company calling then customer
calls outside of the hours they are liable for massive fines for doing
so.
hence why I need to configure by zip code.
If you can find a script that would do this, I would be eternally
grateful.
Yours in hope
Craig
MrBungle50
------------------------------
Date: Sun, 06 Jan 2008 16:30:49 -0800
From: Joseph Brenner <doom@kzsu.stanford.edu>
Subject: Re: minicpan, CPAN/CPANPLUS and autobundles on linux
Message-Id: <8763y6cw92.fsf@kzsu.stanford.edu>
Michele Dondi <bik.mido@tiscalinet.it> writes:
> brian d foy <brian.d.foy@gmail.com> wrote:
>
>>> Since it didn't receive any answers, I replicated your question with
>>> proper attributions at
>>
>>Well, I took a break for an American holiday so I didn't have a chance
>>to answer this one until today.
>>
>>Haven't we gone through this before? I certainly think reposting
>>content without permission, even with attribution, is wrong. Several
>>other people have told you the same thing.
>
> Yes, we've gone through this before. None of the argumentations did
> convince me.
Well, I'm not *greatly* annoyed that you did this, but it's
enitrely possible someone else might've been. It occured to me
that I could post the question to perlmonks, but I thought about
it and decided I would try here first. Why did you take it upon
yourself to do something with my material that I chose not to do?
> the node seems to have been relatively well received -judging
> from its XP-
Right. So you're a karma whore?
Forgive me, but I think my problem was relatively obscure, and I
can't see why you would be so fascinated by it that you couldn't
let it rest.
------------------------------
Date: Sun, 6 Jan 2008 13:49:38 -0800 (PST)
From: Moti <motic.mail@gmail.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <a97ec2a5-52cc-4e1f-9c63-37f64bcdfed9@h11g2000prf.googlegroups.com>
On Jan 4, 4:47=A0pm, Paul Lalli <mri...@gmail.com> wrote:
> On Jan 4, 9:16=A0am, Moti <motic.m...@gmail.com> wrote:
>
> > Hi Guys,
> > After I got my indigoperl to work I want to build an application that
> > get data from the html textarea parse it and then return it to the
> > same text area (deleting the original text).
> > My parser returns a perl array (@output_array) which I want to print
> > to the html text area.
> > Where can I find an example on how to perfrom this ?
>
> perldoc CGI
>
> as an example...
> use CGI qw/:standard/;
> print textarea(
> =A0 =A0-name=3D>'mytext',
> =A0 =A0-rows=3D>10,
> =A0 =A0-columns=3D>50,
> =A0 =A0-default=3D>join('', @output_array)
> );
>
> Paul Lalli
Thanks for your answer Paul, but can I use the above example in order
to write to the same textarea I read from ?
Just to calrify - I dont want to create a new html document - I just
want to read the data from my existing html textarea, process it and
then write it back to the same form.
Another question if I may, It seems that there is a limition on the
size that I can read from my textarea ( I'm reading using the
$text_area_code =3D $cgi->param('text_area_data'); )
It seems that if the textarea contains more than 60 lines an error is
generated by the server.
Lots of questions :) I hope its OK.
Thanks, Moti.
------------------------------
Date: Mon, 07 Jan 2008 00:57:12 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <udt2o3h0g2ffrdhfp0re7rgo4uatr46hm0@4ax.com>
Moti <motic.mail@gmail.com> wrote:
>Thanks for your answer Paul, but can I use the above example in order
>to write to the same textarea I read from ?
Without some trickery like client-side scripting or frames or refresh or
similar no. Once a page is rendered it is rendered. There is nothing the web
server can do to override the page content after it has been sent to the
client. This is a very fundamental design principle of http and has
absolutely nothing to do with Perl.
>Just to calrify - I dont want to create a new html document - I just
>want to read the data from my existing html textarea, process it and
>then write it back to the same form.
This is impossible by design of HTTP. Yes, there are ways to work around the
static nature of web pages but that is about web page programming and has
nothing to do with Perl.
>Another question if I may, It seems that there is a limition on the
>size that I can read from my textarea
>It seems that if the textarea contains more than 60 lines an error is
>generated by the server.
"An error" is about the worst possible description of a problem. _WHAT_
error message are you getting?
Always copy-and-paste, don't retype or paraphrase them. Or even worse don't
keep the text a secret.
jue
------------------------------
Date: Sun, 06 Jan 2008 21:05:08 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <arqdnbQkOq6XOBzanZ2dnUVZ_rDinZ2d@comcast.com>
Jürgen Exner wrote:
> Without some trickery like client-side scripting or frames or refresh or
> similar no.
Or AJAX.
http://search.cpan.org/~bct/CGI-Ajax-0.701/lib/CGI/Ajax.pm
------------------------------
Date: Mon, 07 Jan 2008 04:40:54 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Print a perl array to html textarea ...
Message-Id: <x7fxxa459l.fsf@mail.sysarch.com>
>>>>> "SB" == Scott Bryce <sbryce@scottbryce.com> writes:
SB> Jürgen Exner wrote:
>> Without some trickery like client-side scripting or frames or refresh or
>> similar no.
SB> Or AJAX.
what do you think ajax IS? it is client side scripting but just more
bundled up.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 06 Jan 2008 12:19:17 GMT
From: peter_ha@andres.net (Peter Hanke)
Subject: Search regular expression with search for hex values in files?
Message-Id: <4780c745$0$5949$9b4e6d93@newsspool3.arcor-online.net>
For a given file aaa.txt I want to check wether it contains a hex value e.g. x'77' (=1 byte)
BUT not a hex sequence x'8877' (=two bytes). In other words byte value x'77' should exist
but it must not NOT be preceded by byte value x'88'.
How can I specify this (pre-)conditions in ONE regular expression and pass it e.g. to grep?
Peter
------------------------------
Date: Sun, 6 Jan 2008 21:54:19 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Search regular expression with search for hex values in files?
Message-Id: <flrj45.1do.1@news.isolution.nl>
Peter Hanke schreef:
> For a given file aaa.txt I want to check wether it contains a hex
> value e.g. x'77' (=1 byte) BUT not a hex sequence x'8877' (=two
> bytes). In other words byte value x'77' should exist but it must not
> NOT be preceded by byte value x'88'.
>
> How can I specify this (pre-)conditions in ONE regular expression and
> pass it e.g. to grep?
Where you say 'hex value' I assume you just mean 'character value'
(conveniently presented in hexadecimal format).
m/(?<!\x88)\x77/
See `perldoc perlre`, look for "look-behind assertion".
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: Sat, 5 Jan 2008 18:35:03 -0800 (PST)
From: hikari.no.hohenheim@gmail.com
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <0271e9b0-289a-4460-8c79-832b7c34072f@i29g2000prf.googlegroups.com>
On Jan 5, 5:09 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> Have you tried using the Web Scraping Proxy (wsp.pl) to capture
> the requests that the browser is making?
On Jan 5, 8:26 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> All the information must be explicitely sent by the client (be it the
> browser or your script). So you can use a packet sniffer
> (e.g., wireshark) to compare the requests and see what your script does
> differently than the browser.
I'm checking out these options now. I don't have much experience with
either, but we'll see where it takes me.
The consensus seems to be there is no easy way to simulate a browser
in the sense of having all the incoming content be the result of the
initial request since by default mechanize gets the html source from
the first request and the image or other content as the result of a
second request.
Some way or another I'll have to figure out what information is hidden
from my eyes, and add it to the $mech->get() for the image with $mech-
>add_header or something. Sound about right? Or would anyone care to
articulate this more precisely?
Thanks again!
-Hikari
------------------------------
Date: Sun, 6 Jan 2008 03:25:17 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <t9u555-sj7.ln1@osiris.mauzo.dyndns.org>
Quoth hikari.no.hohenheim@gmail.com:
> On Jan 5, 5:09 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
> > Have you tried using the Web Scraping Proxy (wsp.pl) to capture
> > the requests that the browser is making?
>
> On Jan 5, 8:26 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
> > All the information must be explicitely sent by the client (be it the
> > browser or your script). So you can use a packet sniffer
> > (e.g., wireshark) to compare the requests and see what your script does
> > differently than the browser.
>
> I'm checking out these options now. I don't have much experience with
> either, but we'll see where it takes me.
>
> The consensus seems to be there is no easy way to simulate a browser
> in the sense of having all the incoming content be the result of the
> initial request since by default mechanize gets the html source from
> the first request and the image or other content as the result of a
> second request.
This is exactly the same as what the browser does. There is no way[0]
for a single request to return two objects, so the browser makes two
requests as well. All you need to do is find out what the second request
should be; Tad's suggestion of using the WSP is probably the easiest way
to do that.
[0] mutipart/* aside, as that clearly doesn't apply here.
> Some way or another I'll have to figure out what information is hidden
> from my eyes, and add it to the $mech->get() for the image with $mech-
> >add_header or something. Sound about right? Or would anyone care to
> articulate this more precisely?
No, that sounds about right. Have you tried using $mech->back yet?
WWW::Mech tries quite hard to do all the hard work for you, but it can't
if you don't give it all the information.
Ben
------------------------------
Date: Sun, 06 Jan 2008 14:39:58 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <87zlvj9ioh.fsf@zeekat.nl>
hikari.no.hohenheim@gmail.com writes:
> On Jan 5, 5:09 pm, Tad J McClellan <ta...@seesig.invalid> wrote:
>> Have you tried using the Web Scraping Proxy (wsp.pl) to capture
>> the requests that the browser is making?
>
> On Jan 5, 8:26 am, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> All the information must be explicitely sent by the client (be it the
>> browser or your script). So you can use a packet sniffer
>> (e.g., wireshark) to compare the requests and see what your script does
>> differently than the browser.
>
> I'm checking out these options now. I don't have much experience with
> either, but we'll see where it takes me.
>
> The consensus seems to be there is no easy way to simulate a browser
> in the sense of having all the incoming content be the result of the
> initial request since by default mechanize gets the html source from
> the first request and the image or other content as the result of a
> second request.
No, well at least that's not how I see it: it doesn't matter what is
doing the requests for the images and page, your script or a browser,
it will always first get the page, and then get the images, each as
its own request. *Because you can't do it any other way in HTTP+HTML* If
your code does not give the same result, then either the server is doing
something tricky to associate the requests (which it probably shouldn't
do), or your code doesn't do what you think it does.
Tracing the requests/responses from the browser and your script may give
you an insight what's going wrong.
> Some way or another I'll have to figure out what information is hidden
> from my eyes, and add it to the $mech->get() for the image with $mech-
>>add_header or something. Sound about right? Or would anyone care to
> articulate this more precisely?
Yes, that sounds about right. You may also be interested in
HTTP::Recorder or plain HTTP::Proxy on CPAN.
Joost.
------------------------------
Date: Sun, 6 Jan 2008 09:23:14 -0800 (PST)
From: hikari.no.hohenheim@gmail.com
Subject: Re: WWW::Mechanize : Is immediate caching of images possible?
Message-Id: <c1eec010-9032-4840-bef3-ebc45b83d484@j20g2000hsi.googlegroups.com>
On Jan 6, 8:39 am, Joost Diepenmaat <jo...@zeekat.nl> wrote:
> or your code doesn't do what you think it does.
>
> Tracing the requests/responses from the browser and your script may give
> you an insight what's going wrong.
It ended up being a bit of both but I have a working copy now. wsp
was excellent for diagnosing because it helped me see all the cookies,
session id's, and referer values I needed to double check.
And embarrassingly, I found that the way I was passing my variables
was somehow a bit sloppy and, though it worked with everything else,
it was loosing some cookie/session id information. So I hacked it
with a global variable last night (no need for a lecture) and it
worked, so I'm editing and cleaning up the way I pass the information
in my subroutines now.
All around a very valuable learning experience in a couple of
different categories. Thanks everyone!
(for the record the end result was effectively)
$mech->get($first);
$mech->follow_link($second); #this preserved the referer
$mech->get($imageurl);
Obviously there are a lot more complexities wrapped around it in my
implementation which is why I screwed it up, but looking at that I
feel pretty stupid right about now :-)
-Hikari
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1175
***************************************