[28201] in Perl-Users-Digest
Perl-Users Digest, Issue: 9565 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 5 03:05:43 2006
Date: Sat, 5 Aug 2006 00:05:07 -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 Sat, 5 Aug 2006 Volume: 10 Number: 9565
Today's topics:
Re: Hash in inherited object fields not properly access <shenkin@gmail.com>
Re: Hash in inherited object fields not properly access <uri@stemsystems.com>
Re: Hash in inherited object fields not properly access <uri@stemsystems.com>
Re: How to "convert" a string into a variable name? <nospam@somewhere.com>
Re: How to "convert" a string into a variable name? <uri@stemsystems.com>
Re: How to "convert" a string into a variable name? <1usa@llenroc.ude.invalid>
new CPAN modules on Sat Aug 5 2006 (Randal Schwartz)
PERL ---> Move email from Inbox folder to another or vi bony_dev@yahoo.com
Re: Perl hash of hash efficiency. <benmorrow@tiscali.co.uk>
Re: Perl hash of hash efficiency. <1usa@llenroc.ude.invalid>
Re: Perl hash of hash efficiency. <1usa@llenroc.ude.invalid>
Re: Pod::Parser not recognising "interior sequences" <sisyphus1@nomail.afraid.org>
Re: Reading HTTP response body that is gzip'd *and* in <benmorrow@tiscali.co.uk>
the perens in lisp dilects is there for a reson... macr atbusbook@aol.com
Using s///g to remove carriage returns <jwcarlton@gmail.com>
Re: Using s///g to remove carriage returns <xicheng@gmail.com>
Re: Using s///g to remove carriage returns <mikeh@perusion.net>
Re: Using s///g to remove carriage returns <rvtol+news@isolution.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Aug 2006 19:48:45 -0700
From: "PeterSShenkin" <shenkin@gmail.com>
Subject: Re: Hash in inherited object fields not properly accessible (5.8.6, RH 7.3)
Message-Id: <1154746125.362290.92660@i42g2000cwa.googlegroups.com>
Uri Guttman wrote:
> did you iterate over that object hash in some other code before that
> code is called? if so, that could have exhausted the iterator and you
> are getting back the end of iteration empty list. the call to scalar
> keys resets the hash iterator. your data is there ...
Yes, I knew the data were there -- just the fact that adding the call
to "keys" allowed the iteration showed that. And in fact I had also
printed the object with Data::Dumper.
Your suggestion is interesting -- even likely, though I'm not aware of
having done such iteration. I'll have to do some careful examination
to determine where/whether this is occurring. It's not impossible.
Is there by any chance some trick that one can use to obtain the
current state of the iterator without actually iterating?
Thanks,
-P.
------------------------------
Date: Fri, 04 Aug 2006 21:24:24 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Hash in inherited object fields not properly accessible (5.8.6, RH 7.3)
Message-Id: <x7zmekq8jb.fsf@mail.sysarch.com>
>>>>> "P" == PeterSShenkin <shenkin@gmail.com> writes:
P> In the course of inserting printouts to determine what was going on, I
P> discovered that computing ntype_stats as shown below causes the "while"
P> to behave properly. Presumably, the call to "keys" makes the hash
P> contents visible.
P> Apologies if this is a known bug; if so, please refer me to where it is
P> documented.
P> sub compute_base {
P> # compute() each child and return hash of results:
P> my $self = shift;
P> # the while finds no k,v pairs on the 1st call to compute_base
P> # without the following line; this seems to be a bug in Perl:
P> my $ntype_stats = scalar keys %{$self->{type_stats}};
P> while( my ($k,$v) = each %{$self->{type_stats}} ) {
P> $results->{$k} = $v->compute($nsample);
P> }
did you iterate over that object hash in some other code before that
code is called? if so, that could have exhausted the iterator and you
are getting back the end of iteration empty list. the call to scalar
keys resets the hash iterator. your data is there (try printing it with
data::dumper) but your hash's iterator is at the end (somehow you left
it there). see perldoc -f each for more on hash iterators. and you don't
need to assign to $ntype_stats, the keys call in void or scalar context
will reset the iterator.
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: Sat, 05 Aug 2006 00:06:53 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Hash in inherited object fields not properly accessible (5.8.6, RH 7.3)
Message-Id: <x7irl7rfky.fsf@mail.sysarch.com>
>>>>> "P" == PeterSShenkin <shenkin@gmail.com> writes:
P> Uri Guttman wrote:
>> did you iterate over that object hash in some other code before that
>> code is called? if so, that could have exhausted the iterator and you
>> are getting back the end of iteration empty list. the call to scalar
>> keys resets the hash iterator. your data is there ...
P> Yes, I knew the data were there -- just the fact that adding the call
P> to "keys" allowed the iteration showed that. And in fact I had also
P> printed the object with Data::Dumper.
P> Your suggestion is interesting -- even likely, though I'm not aware of
P> having done such iteration. I'll have to do some careful examination
P> to determine where/whether this is occurring. It's not impossible.
i trust perl more than i trust your eyes :). i would find it odd that
your code did that but who knows? the fact that resetting the iterator
fixes it tells me that you must have done some iterating before. i would
have to examine all the earlier code to find out but you will be doing
that. when you find it and smack your head, let us know! :) if you can
post all the other related code, maybe more eyes could find the
problem. can you reduce the problem to a short runnable script? maybe
just the constructor and/or some called methods might show the problem.
P> Is there by any chance some trick that one can use to obtain the
P> current state of the iterator without actually iterating?
not from the level of perl code AFAIK. all you can do is reset it and
then iterate until you get an end of hash marker from each (empty list
or undefined key). note that values also resets the iterator and you
will always get a fresh iteration whenever you call values or keys or
have the hash in a list context. besides, what kind of state would an
iterator return but the next key or the end of keys marker? internally
the iterator is just a pointer to the next key in the hash buckets.
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: Fri, 4 Aug 2006 23:33:55 -0400
From: "Anonymous" <nospam@somewhere.com>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <NcidnWamg7Y4jEnZnZ2dnUVZ_sydnZ2d@comcast.com>
This message group is NOT a programming class, it is a forum where people
can ask questions about Perl and others can HELP them. Just because YOU
don't think it is good programming practice is no reason not to answer the
OP's question. Your idea of help is to berate and bully posters, lecture on
what you think is good practice, what you think is not good practice, how to
post, read the FAQ, read the docs, etc., etc. This is the most arrogant
newsgroup on the 'net, and your presence here is the number one contributor
to that attitude. Quite frankly this newsgroup would be a much better and
NICER place without you.
Scott
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
news:Xns9814D1682D4D4asu1cornelledu@127.0.0.1...
> "thrill5" <nospam@comcast.net> wrote in
> news:Naydnds0WNMhDk_ZnZ2dnUVZ_umdnZ2d@comcast.com:
>
> First, do not top-post.
>
>> I think this is what you had in mind:
>>
>> $TempOut = 25;
>> $name = "TempOut";
>> print $$name;
>
> Second, it has already been explained that this is not a good idea.
>
> Please do read the FAQ:
>
> perldoc -q "How can I use a variable as a variable name"
>
> Sinan
> --
> A. Sinan Unur <1usa@llenroc.ude.invalid>
> (remove .invalid and reverse each component for email address)
>
> comp.lang.perl.misc guidelines on the WWW:
> http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
>
------------------------------
Date: Fri, 04 Aug 2006 23:57:03 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <x7mzajrg1c.fsf@mail.sysarch.com>
>>>>> "A" == Anonymous <nospam@somewhere.com> writes:
A> This message group is NOT a programming class, it is a forum where
A> people can ask questions about Perl and others can HELP them. Just
A> because YOU don't think it is good programming practice is no
A> reason not to answer the OP's question. Your idea of help is to
A> berate and bully posters, lecture on what you think is good
A> practice, what you think is not good practice, how to post, read
A> the FAQ, read the docs, etc., etc. This is the most arrogant
A> newsgroup on the 'net, and your presence here is the number one
A> contributor to that attitude. Quite frankly this newsgroup would
A> be a much better and NICER place without you.
when you start answering all those FAQ's yourself and consistantly do it
in your nicest way, then we will stop doing the job in our way. as for
the actual request to use symrefs, if you actually think telling a
newbie how to do such an evil thing is a good idea, then you must also
like showing schoolkids how to load and use machine guns. they are about
the same level of nastiness.
maybe you don't realize that symrefs are JUST USING THE SYMBOL TABLE AS
A DATA STRUCTURE. can you see that using a hash for that would be
faster, safer, cleaner, better in all possible ways? if not, you should
not be flaming anyone here but i think you know that, don't you? now if
you go away then this group will become much nicer. in fact much nicer
than if sinan went away.
and to top it off, you top posted which is against this groups
guidelines. you have read those haven't you? they advocate looking for
answers in the faq.
and as for what this group is, you have no foundation to say anything
about that until you have been answering questions on a long term basis
and others grant you the respect based on your skills. note that trolls
like robic and moronzilla don't qualify but at least they sometimes
discuss perl itself unlike your silly useless rant.
and it is not a forum or a message group. it is a usenet or netnews
group. but of course you know that since you rule here.
have a nice coding experience without help from me or most of the
regulars here. i will make sure to not hire you too.
yours sincerely,
a much bigger clpm cop than you will ever be,
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: Sat, 05 Aug 2006 05:40:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: How to "convert" a string into a variable name?
Message-Id: <Xns98161124B5DA5asu1cornelledu@127.0.0.1>
"Anonymous" <nospam@somewhere.com> wrote in
news:NcidnWamg7Y4jEnZnZ2dnUVZ_sydnZ2d@comcast.com:
[ Please do not top-post. Please do not quote signatures. ]
> "A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in message
> news:Xns9814D1682D4D4asu1cornelledu@127.0.0.1...
>> "thrill5" <nospam@comcast.net> wrote in
>> news:Naydnds0WNMhDk_ZnZ2dnUVZ_umdnZ2d@comcast.com:
>>
>> First, do not top-post.
>>
>>> I think this is what you had in mind:
>>>
>>> $TempOut = 25;
>>> $name = "TempOut";
>>> print $$name;
>>
>> Second, it has already been explained that this is not a good idea.
>>
>> Please do read the FAQ:
>>
>> perldoc -q "How can I use a variable as a variable name"
>
> This message group is NOT a programming class, it is a forum where
> people can ask questions about Perl and others can HELP them. Just
> because YOU don't think it is good programming practice is no reason
> not to answer the OP's question.
The OP's question has been answered. The OP is a rational person who saw
the value of using a hash in this case, and the potential problems with
using a symref
> Your idea of help is to berate and bully posters,
There is no bullying above. Just a reminder that using symrefs is not a
good idea most of the time, and a pointer to the FAQ where the reasons for
the caution are well explained
> lecture on what you think is good practice, what you
> think is not good practice, how to post, read the FAQ, read the docs,
> etc., etc. This is the most arrogant newsgroup on the 'net, and your
> presence here is the number one contributor to that attitude.
Thank you for holding me in such high esteem.
> Quite frankly this newsgroup would be a much better and NICER place
> without you.
>
> Scott
I post what I feel is the right response to each post. Thoughtful
questions posted by rational people get thoughtful responses. Sometimes I
can provide a solution, sometimes I make mistakes, and I learn from
corrections. That is the benefit of this group to me: Learning by trying
to answer questions, and by reading others' corrections of my posts.
Posts made without any effort, without even checking the FAQ list, or the
documentation for functions used etc subtract from that value, and
therefore I try to discourage them.
Feel free to ignore me. However, let me at least point out that I do not
hide behind anonymous handles when I post. Come back when you actually
develop the courage back up your posts.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sat, 5 Aug 2006 04:42:07 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sat Aug 5 2006
Message-Id: <J3ID27.1E2x@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Algorithm-CRF-0.01
http://search.cpan.org/~clsung/Algorithm-CRF-0.01/
Perl extension for blah blah blah
----
Algorithm-CRF-0.02
http://search.cpan.org/~clsung/Algorithm-CRF-0.02/
Perl binding for CRF++
----
Apache2-xForwardedFor-0.02
http://search.cpan.org/~jvanasco/Apache2-xForwardedFor-0.02/
Re-set remote_ip to incoming client's ip when running mod_perl behind a reverse proxy server. In other words, copy the first IP from X-Forwarded-For header, which was set by your reverse proxy server,
----
Apache2-xForwardedFor-0.03
http://search.cpan.org/~jvanasco/Apache2-xForwardedFor-0.03/
Re-set remote_ip to incoming client's ip when running mod_perl behind a reverse proxy server. In other words, copy the first IP from X-Forwarded-For header, which was set by your reverse proxy server,
----
Authen-PluggableCaptcha-0.01
http://search.cpan.org/~jvanasco/Authen-PluggableCaptcha-0.01/
A pluggable Captcha system for Perl
----
CGI-Application-Plugin-PageBuilder-0.9.1_1
http://search.cpan.org/~cmoore/CGI-Application-Plugin-PageBuilder-0.9.1_1/
Simplifies building pages with multiple templates.
----
Chart-Clicker-1.0.0
http://search.cpan.org/~gphat/Chart-Clicker-1.0.0/
Powerful, extensible charting.
----
Class-Constant-0.01
http://search.cpan.org/~robn/Class-Constant-0.01/
Build constant classes
----
DBD-DB2-0.80
http://search.cpan.org/~ibmtordb2/DBD-DB2-0.80/
DataBase Driver for DB2 UDB
----
DBIx-VersionedSubs-0.03
http://search.cpan.org/~corion/DBIx-VersionedSubs-0.03/
all your code are belong into the DB
----
Data-LazyACL-0.02
http://search.cpan.org/~tomyhero/Data-LazyACL-0.02/
Simple and Easy Access Control List
----
Data-LazyACL-0.03
http://search.cpan.org/~tomyhero/Data-LazyACL-0.03/
Simple and Easy Access Control List
----
Data-Password-1.07
http://search.cpan.org/~razinf/Data-Password-1.07/
Perl extension for assesing password quality.
----
Data-SimplePassword-0.01
http://search.cpan.org/~ryochin/Data-SimplePassword-0.01/
Simple random password generator
----
MDV-Repsys-0.05
http://search.cpan.org/~nanardon/MDV-Repsys-0.05/
----
Perlbal-1.42
http://search.cpan.org/~bradfitz/Perlbal-1.42/
Reverse-proxy load balancer and webserver
----
Pod-Coverage-0.18
http://search.cpan.org/~rclamp/Pod-Coverage-0.18/
Checks if the documentation of a module is comprehensive
----
RT-Client-REST-0.22
http://search.cpan.org/~dmitri/RT-Client-REST-0.22/
talk to RT installation using REST protocol.
----
RT-Client-REST-0.23
http://search.cpan.org/~dmitri/RT-Client-REST-0.23/
talk to RT installation using REST protocol.
----
RTx-Timeline-0.02
http://search.cpan.org/~htchapman/RTx-Timeline-0.02/
----
SVK-Log-Filter-Babelfish-0.0.3
http://search.cpan.org/~mndrix/SVK-Log-Filter-Babelfish-0.0.3/
translate logs to various natural languages
----
SVK-Log-Filter-Mndrix-0.0.2
http://search.cpan.org/~mndrix/SVK-Log-Filter-Mndrix-0.0.2/
my pretty-ish output format
----
SVK-Log-Filter-Stats-0.0.4
http://search.cpan.org/~mndrix/SVK-Log-Filter-Stats-0.0.4/
display cumulative statistics for revisions
----
Sledge-Config-YAML-0.02
http://search.cpan.org/~mikihoshi/Sledge-Config-YAML-0.02/
The configuration file of Sledge can be written by using YAML.
----
Text-Find-Scalar-0.03
http://search.cpan.org/~reneeb/Text-Find-Scalar-0.03/
Find scalar names in a text.
----
Text-Find-Scalar-0.04
http://search.cpan.org/~reneeb/Text-Find-Scalar-0.04/
Find scalar names in a text.
----
Util-Properties-0.02
http://search.cpan.org/~alexmass/Util-Properties-0.02/
Java.util.properties like class
----
Util-Properties-0.03
http://search.cpan.org/~alexmass/Util-Properties-0.03/
Java.util.properties like class
----
Util-Properties-0.04
http://search.cpan.org/~alexmass/Util-Properties-0.04/
Java.util.properties like class
----
mogilefs-server-2.00_01
http://search.cpan.org/~bradfitz/mogilefs-server-2.00_01/
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
print "Just another Perl hacker," # the original
--
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: 4 Aug 2006 19:39:39 -0700
From: bony_dev@yahoo.com
Subject: PERL ---> Move email from Inbox folder to another or vice versa in OUTLOOK
Message-Id: <1154745579.934674.261400@p79g2000cwp.googlegroups.com>
Hello Gurus,
I am trying to write a perl script that will move an email message from
one folder to another folder in OUTLOOK using WIN32:OLE. Is there any
meathod to do so? If anybody has done it, please let me know...Thanks a
lot..
-Bony
------------------------------
Date: Fri, 4 Aug 2006 23:40:12 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Perl hash of hash efficiency.
Message-Id: <cvucq3-62m.ln1@osiris.mauzo.dyndns.org>
Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> "tak" <yekasi@gmail.com> wrote in news:1154727416.683423.205940
> @i3g2000cwc.googlegroups.com:
>
> > open(mainfile)
>
> Wot?
open(mainfile) is valid (from Perl4) code, which opens *mainfile{IO} to
the file named in $mainfile (or rather $::mainfile, since it always uses
the global).
>
> or die("Could not open master file
> > '$mainfile'.");
> > foreach my $line (<mainfile>) {
>
> Haven't you read any of the responses??? I pointed this out as a distinct
> possibility. You are slurping the entire file, just to process it line by
> line.
Given how common this mistake is (for vs. while for reading a file), and
that for is probably a more obvious idiom for iterating over all the
lines in the file, would there be any point suggesting this to p5p as an
optimization along the lines of for (1..100_000) ? I can't see a good
reason why for (<$FH>) {} actually *has* to build the list of lines
first, or indeed when it would be helpful for it to do. I suppose some
obscure situation involving seeking and overwriting inside the loop?
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. benmorrow@tiscali.co.uk
------------------------------
Date: Sat, 05 Aug 2006 05:10:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl hash of hash efficiency.
Message-Id: <Xns9816C002E51Aasu1cornelledu@127.0.0.1>
Ben Morrow <benmorrow@tiscali.co.uk> wrote in
news:cvucq3-62m.ln1@osiris.mauzo.dyndns.org:
>
> Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
>> "tak" <yekasi@gmail.com> wrote in news:1154727416.683423.205940
>> @i3g2000cwc.googlegroups.com:
>>
>> > open(mainfile)
>>
>> Wot?
>
> open(mainfile) is valid (from Perl4) code, which opens *mainfile{IO}
> to the file named in $mainfile (or rather $::mainfile, since it always
> uses the global).
Well, thanks to you and Jim Gibson for catching this. I did not know and I
am kind of glad I did not ;-) But, as I say, I learn something new
everyday.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sat, 05 Aug 2006 05:25:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl hash of hash efficiency.
Message-Id: <Xns9816E8D7134Casu1cornelledu@127.0.0.1>
"tak" <yekasi@gmail.com> wrote in
news:1154732291.613125.161650@b28g2000cwb.googlegroups.com:
>
> A. Sinan Unur wrote:
>> "tak" <yekasi@gmail.com> wrote in news:1154727416.683423.205940
>> @i3g2000cwc.googlegroups.com:
...
>>
>> or die("Could not open master file
>> > '$mainfile'.");
>> > foreach my $line (<mainfile>) {
>>
>> Haven't you read any of the responses??? I pointed this out as a
>> distinct possibility. You are slurping the entire file, just to
>> process it line by line.
>
>
> I did read all the responses.
Maybe you did not read
http://groups.google.com/group/comp.lang.perl.misc/msg/9b76dbedafcea16
which showed using a while loop to read the file line by line.
> I do not know what you mean by
> "Slurping", sorry, i am not a native english speaker.Slurping is not a
> technical term that you can learn in a Perl book, nor any of the tech
> books that you can find in barnes and noble.
Perl Cookbook, 2nd edition, page 302 in Chapter 8 "File Contents"
http://search.barnesandnoble.com/booksearch/results.asp?WRD=perl+cookbook&z=y&cds2Pid=9481
Programming Perl, 3rd edition, "slurping files" in index, refers to
pages 492 and 1002.
http://search.barnesandnoble.com/booksearch/results.asp?WRD=programming+perl&z=y
...
> no FOREACH. And by looking at the next useful comments made by the
> next poster - he mentioned that i should not be using foreach, use
> while instead. You could've say the same thing - but
See the message referenced above. Even though you had not posted any code
at that time, I correctly diagnosed your problem, and posted the correct
way to read files line by line a few hours before you posted code.
> you are not in a
> position to say i wasted your time trying to guess what my issue was.
How many responses did take the diagnose the issue? How many responses
would it have taken had you posted code in the first place? The difference
corresponds to wasted time because you did not take time to post enough
information.
> And as for you will not be seeing me - OK. If that makes you feel
> better.
Well, I had forgotten to add you to my killfile.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Sat, 5 Aug 2006 13:07:10 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Pod::Parser not recognising "interior sequences"
Message-Id: <44d40c4f$0$5109$afc38c87@news.optusnet.com.au>
"Henry Law" <news@lawshouse.org> wrote in message
news:1154729221.11222.0@proxy02.news.clara.net...
.
.
>
> I'm writing a simple Pod parsing module. So far all it does is subclass
> some of the methods from Pod::Parser, but the "interior_sequence"
> subroutine doesn't ever seem to be called.
Looking at the Pod::Parser source, 'textblock' calls 'interpolate', which
calls 'parse_text', which calls 'interior_sequence'. (At least, that appears
to be *one* pathway to the calling of 'interior_sequence'.)
But there's nothing in HTMLDoc.pm that's going to lead to
'interior_sequence' being called.
Cheers,
Rob
------------------------------
Date: Sat, 5 Aug 2006 00:17:49 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Reading HTTP response body that is gzip'd *and* in UTF-8
Message-Id: <t51dq3-k2q.ln1@osiris.mauzo.dyndns.org>
Quoth james@jmarshall.com:
> I'm writing an HTTP client that handles gzip'd content as well as UTF-8
> text, including when a response body is both gzip'd and in UTF-8.
>
> I'm newish to both compression and PerlIO layers, so I'd like a second
> opinion from someone who knows them better than I do. Does the code below
> look correct? The goal is to end up with the uncompressed body in $body,
> and interpreted as UTF-8 if identified as such by "charset".
>
> I appreciate not wanting to use utf8::upgrade() ; is there a better way to
> handle it in this case, or is this one of those cases where it's
> legitimately needed?
It's never (IMHO) legitimately needed. The only possible case is where
some XS code has messed something up. utf8::upgrade doesn't change
anything that's visible at the Perl level. All it does is change how
perl represents the data internally, but you don't care about that.
> Finally, does anyone know if Compress::Zlib::memGzip() handles UTF-8 input
> correctly, or do I need to "utf8::downgrade($body)" before compressing it?
I don't know what Compress::Zlib does aobut it, but it's pretty
meaningless to apply gzip to a stream of characters. It's not defined on
characters, it's defined on bytes; so you need to convert from
characters to bytes. This is Encode::encode, or the :encoding layer on
output.
>
> =======================================================
>
> use Compress::Zlib ;
>
> # Assume S is the socket, and $is_gzipped and $is_utf8 are set correctly
> # from the HTTP response headers, which have just been read from S.
>
> if ($is_gzipped) {
> $body= &read_full_body(S) ;
Don't call subs with & unless you know why.
> $body= Compress::Zlib::memGunzip($body) ;
Is there a good reason why you're not using PerlIO::gzip? (I've never
used it, so there may be some reason it doesn't work I'm not aware
of...?)
> if ($is_utf8) {
> utf8::upgrade($body) ;
This should be either
utf8::decode($body);
or (preferably)
$body = Encode::decode(utf8 => $body);
(and then you can handle all the other charsets the same way: just pass
Encode the value of the charset MIME parameter).
I would have written this more like
# push gzip first: closer to the outside world
# +---------+ +-----+
# program <--> |:encoding| <--> |:gzip| <--> socket
# +---------+ +-----+
if (is_gzip) {
binmode S, ':gzip';
}
my $charset = get_charset;
binmode S, ":encoding($charset)";
# read data... when you've finished, and want the next request:
binmode S, ':pop:pop';
and then just read or write characters.
Ben
--
The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching.
Assyrian stone tablet, c.2800 BC benmorrow@tiscali.co.uk
------------------------------
Date: 4 Aug 2006 23:42:10 -0700
From: atbusbook@aol.com
Subject: the perens in lisp dilects is there for a reson... macros.
Message-Id: <1154760130.279122.148460@75g2000cwc.googlegroups.com>
macros are sort of like c macros but more powerful. they are the
manafestation of treating code like data. lisp code is just a textual
representation of a data structure that is the list. this means that
you can manipulate code to emulate structured controll constructs and
elemanate boilerplate code. to show you the power of a macro heer is a
while loop
<code>
(defmacro while (test &body body)
`(do ()
((not ,test))
,@body)
</code>
Another one would be untill
<code>
(defmacro untill (test &body body)
`(while (not ,test) ,@body))
</code>
wich is defined on top of while
another test to wead out programers would be lisp stile macros because
of variable capture
and other perls of the macro world. but higenic macros can not have the
power of true macros
i also hear you talk about introspection. in lisp you use eval list
lets define a sum function to show you
<code>
(defun sum (lst)
(eval (append '(+) lst)))
</code>
another example would be this
<code>
(loop (print (eval (read))))
</code>
this is an interactive top level in 1 line
another use is for calling of functions
<code>
(defvar cmds `('foo ,(lambda () (format t "hello world")))
(funcall (getf cmds (read-from-string (read-line))))
</code>
of corse no error checking for comas and other things that could crash
the program
------------------------------
Date: 4 Aug 2006 21:04:29 -0700
From: "Jason" <jwcarlton@gmail.com>
Subject: Using s///g to remove carriage returns
Message-Id: <1154750669.393148.154110@i3g2000cwc.googlegroups.com>
I've gone through about a dozen options, and none of them work
correctly! This is driving me nuts.
The request is pretty simple: I have a form with a textarea field, and
I want to remove any opening or trailing carriage returns from it
(while leaving any return in the middle). This is the code I tried most
recently, and was certain would work:
$comment =~ s/^\r\n+|^\r+|^\n+|\r\n+$|\r+$|\n+$//g;
But, it doesn't seem to have any impact at all! Correct me if I'm
wrong, but I thought that this broke down like:
s/ # substitute
^\r\n+| # start at the beginning, find all \r\n until you find
something else, OR
^\r+| # same as above, finding only \r, OR
^\n+| # same, finding only \n, OR
\r\n+$| # finding all \r\n that go to the end uninterrupted, OR
\r+$| # same, finding only \r, OR
\n+$ # same, finding only \n
// # replace any of the above with nothing
g; # do this globally
I also tried breaking it down into 2 separate recipes, which had no
impact:
$comment =~ s/^\r\n+|^\r+|^\n+//g;
$comment =~ s/\r\n+$|\r+$|\n+$//g;
Not surprisingly, this one DOES work to remove whitespaces (taken from
the FAQ):
$comment =~ s/^\s+|\s+$//g;
This should be the same thing as my recipe above, but instead of \s,
I've used \r, \n, or some variation.
Do you guys see what I'm overlooking?
TIA,
Jason
------------------------------
Date: 4 Aug 2006 21:43:33 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Using s///g to remove carriage returns
Message-Id: <1154753013.308729.287400@h48g2000cwc.googlegroups.com>
Jason wrote:
> I've gone through about a dozen options, and none of them work
> correctly! This is driving me nuts.
>
> The request is pretty simple: I have a form with a textarea field, and
> I want to remove any opening or trailing carriage returns from it
> (while leaving any return in the middle). This is the code I tried most
> recently, and was certain would work:
>
> $comment =~ s/^\r\n+|^\r+|^\n+|\r\n+$|\r+$|\n+$//g;
>
> But, it doesn't seem to have any impact at all! Correct me if I'm
> wrong, but I thought that this broke down like:
>
> s/ # substitute
> ^\r\n+| # start at the beginning, find all \r\n until you find
> something else, OR
> ^\r+| # same as above, finding only \r, OR
> ^\n+| # same, finding only \n, OR
> \r\n+$| # finding all \r\n that go to the end uninterrupted, OR
> \r+$| # same, finding only \r, OR
> \n+$ # same, finding only \n
> // # replace any of the above with nothing
> g; # do this globally
>
> I also tried breaking it down into 2 separate recipes, which had no
> impact:
>
> $comment =~ s/^\r\n+|^\r+|^\n+//g;
> $comment =~ s/\r\n+$|\r+$|\n+$//g;
>
>
> Not surprisingly, this one DOES work to remove whitespaces (taken from
> the FAQ):
>
> $comment =~ s/^\s+|\s+$//g;
>
> This should be the same thing as my recipe above, but instead of \s,
> I've used \r, \n, or some variation.
>
> Do you guys see what I'm overlooking?
>
bash~ $ perl -e '
$_="\n\n\n\r\rI am \n\n\r\r";
s/^\r\n+|^\r+|^\n+|\r\n+$|\r+$|\n+$//g;
print' | cat -A
___print___
^M^MI am $
$
__________
So you know what your regex does, don't you?
If you want to remove both \r and \n in any order, try the following:
$comment =~ s/^[\r\n]+|[\r\n]+$//g;
Xicheng
------------------------------
Date: Sat, 05 Aug 2006 04:43:47 -0000
From: Mike Heins <mikeh@perusion.net>
Subject: Re: Using s///g to remove carriage returns
Message-Id: <slrned88g2.p4e.mikeh@bill.heins.net>
On 2006-08-05, Jason <jwcarlton@gmail.com> wrote:
> I've gone through about a dozen options, and none of them work
> correctly! This is driving me nuts.
>
> The request is pretty simple: I have a form with a textarea field, and
> I want to remove any opening or trailing carriage returns from it
> (while leaving any return in the middle). This is the code I tried most
> recently, and was certain would work:
>
> $comment =~ s/^\r\n+|^\r+|^\n+|\r\n+$|\r+$|\n+$//g;
>
> But, it doesn't seem to have any impact at all!
Without knowing what is handing you the data from the "textarea field"
I can't know what you are getting. But this should always serve:
$comment =~ s/^[\r\n]+//;
$comment =~ s/[\r\n]+$//;
It is of course possible that you have other whitespace at the beginning
too -- it would be pretty normal to instead simply do:
$comment =~ s/^\s+//;
$comment =~ s/\s+$//;
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
Be patient. God isn't finished with me yet. -- unknown
------------------------------
Date: Sat, 5 Aug 2006 06:49:22 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Using s///g to remove carriage returns
Message-Id: <eb1fg2.s0.1@news.isolution.nl>
Jason schreef:
> none of them work correctly!
ITYM: none of them work as you expected.
> ^\r\n+| # start at the beginning, find all \r\n until you find
> something else, OR
ITYM: ^(?:\r\n)+
> \r\n+$| # finding all \r\n that go to the end uninterrupted, OR
ITYM: (?:\r\n)+$
Still, if
s{ ^\s+ | \s+$ }{}xg
works, then why complicate things?
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
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 9565
***************************************