[28166] in Perl-Users-Digest
Perl-Users Digest, Issue: 9530 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 27 09:10:14 2006
Date: Thu, 27 Jul 2006 06:10:08 -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, 27 Jul 2006 Volume: 10 Number: 9530
Today's topics:
Re: How to send utf-8 data using LWP::UserAgent? <g111@netcologne.de>
Re: How to send utf-8 data using LWP::UserAgent? <benmorrow@tiscali.co.uk>
Re: How to send utf-8 data using LWP::UserAgent? <flavell@physics.gla.ac.uk>
How to use threads to parallelise 4 different DB connec <go4anju@gmail.com>
new CPAN modules on Thu Jul 27 2006 (Randal Schwartz)
Re: Please confirm bug in SHLOMIF > Error-0.17 > Error <1usa@llenroc.ude.invalid>
pod question <ferry.bolhar@chello.at>
Re: pod question anno4000@radom.zrz.tu-berlin.de
Re: Uninitialized value errors <josef.moellers@fujitsu-siemens.com>
Re: Uninitialized value errors anno4000@radom.zrz.tu-berlin.de
Re: Using an input/csv file to rename files axel@white-eagle.invalid.uk
Re: What is the right syntax? <bernard.el-haginDODGE_THIS@lido-tech.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 27 Jul 2006 11:44:15 +0200
From: Gert Brinkmann <g111@netcologne.de>
Subject: Re: How to send utf-8 data using LWP::UserAgent?
Message-Id: <eaa1tg$cmu$1@newsreader2.netcologne.de>
Thank you, Ben,
with this information I have to reread the utf8- and Encode-perldocs to
really "internalize"(?) this topic.
Ben Morrow wrote:
>> Encode::_utf8_on($x);
>
> NO! You should never need to call the _utf8_o{n,ff} functions.
But what are you doing if you receive a CGI-parameter that was sent from a
web-browser in utf-8? On server side AFAIK you do not get the information
from http which charset was used. If you know that the script is working in
your completely utf-8 enabled web-application it should be utf-8. But is
the $parameter CGI variable correctly tagged as utf-8 by the CGI module? In
my understanding it receives utf-8 textstrings and stores it into an
non-utf-8 variable that has to be utf-8-tagged by yourself. Isn't it?
Thanks,
Gert
------------------------------
Date: Thu, 27 Jul 2006 11:17:51 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: How to send utf-8 data using LWP::UserAgent?
Message-Id: <ffgmp3-7rg.ln1@osiris.mauzo.dyndns.org>
Quoth Gert Brinkmann <g111@netcologne.de>:
>
> Thank you, Ben,
>
> with this information I have to reread the utf8- and Encode-perldocs to
> really "internalize"(?) this topic.
The most important point (and I'm not sure the Perl docs currently make
this entirely clear) is that you always have to know whether a given
string is a sequence of *characters* or a sequence of *bytes*. This is
not the same as whether the perl-internal utf8 flag is on, due to perl's
back-compat stuff.
Basically, all input is in bytes, and all text data should be decoded to
characters before processing. Binary data obviously shouldn't. So on
input (from any source that doesn't do the decoding for you) you need to
determine (somehow) what charset the data is expected to be in, and
decode it. Then on output (again to any source that outputs bytes
directly) you need to decide (somehow) what charset you want and encode
the data before output.
One way of making this easier is to push the :encoding layer onto a
filehandle (see PerlIO::encoding): this does the de/encoding for you
automatically so the filehandle now appears to be a stream of characters
rather than a stream of bytes.
[Note to pacify Alan :): my use of the term 'charset' above (and yours
below) corresponds to the MIME paramater of the same name, rather than
to a 'character set' proper]
> Ben Morrow wrote:
> >> Encode::_utf8_on($x);
> >
> > NO! You should never need to call the _utf8_o{n,ff} functions.
>
> But what are you doing if you receive a CGI-parameter that was sent from a
> web-browser in utf-8? On server side AFAIK you do not get the information
> from http which charset was used. If you know that the script is working in
> your completely utf-8 enabled web-application it should be utf-8. But is
> the $parameter CGI variable correctly tagged as utf-8 by the CGI module? In
> my understanding it receives utf-8 textstrings and stores it into an
> non-utf-8 variable that has to be utf-8-tagged by yourself. Isn't it?
I don't really understand the situation you're describing (but then my
knowledge of CGI programming is somewhat limited). Are you saying the
data is known to be in UTF8, or that you don't know what charset it's
in?
A string that contains a sequence of bytes that happen to be valid UTF8
is not at all the same thing as a string that contains the sequence of
characters represented by those bytes. In fact, converting from one to
the other is what the Encode::decode function is for.
The internal utf8 flag *does not* mean 'this string is in UTF8' in any
sense that matters to a user of Perl. What it means is 'this string
contains characters rather than bytes, *AND* some of those characters
are above 0xff'. Or sometimes '... *AND* some of those characters used
to be above 0xff but aren't any more, but I haven't noticed that yet'.
Do you begin to see now why this is a property of the string you really
don't care about?
Ben
--
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces mollit animos, tristesque mentes erigit.|benmorrow@tiscali.co.uk
Musica vel ipsas arbores et horridas movet feras. |
------------------------------
Date: Thu, 27 Jul 2006 11:40:50 +0100
From: "Alan J. Flavell" <flavell@physics.gla.ac.uk>
Subject: Re: How to send utf-8 data using LWP::UserAgent?
Message-Id: <Pine.LNX.4.64.0607271124470.17621@ppepc87.ph.gla.ac.uk>
On Thu, 27 Jul 2006, Gert Brinkmann wrote:
> Ben Morrow wrote:
> >> Encode::_utf8_on($x);
> >
> > NO! You should never need to call the _utf8_o{n,ff} functions.
>
> But what are you doing if you receive a CGI-parameter that was sent
> from a web-browser in utf-8?
An interesting question - but not, I think, a question to which the
answer could ever be _utf8_on($x)
> On server side AFAIK you do not get the information
> from http which charset was used.
The simplest case (and recommended, except that the old NN4.* does not
work, if anybody still cares), is to send out the page which contains
the form, as utf-8, and the browser will respond by submitting the
form in utf-8 encoding.
More complex things can happen if Accept-charset is used. I don't
think I would want to go there, as there seems to be no advantage in
it.
Some browsers, in some situations, unilaterally add to the submitted
data an extra name=value pair, with the name "_charset_" and the value
being the submission encoding that they are using. You can't rely on
getting this, though.
> But is the $parameter CGI variable correctly tagged as utf-8 by the
> CGI module?
"tagging as utf-8" is something which Perl does behind the scenes when
you apply appropriate encode/decode operations on data. Except in
some very obscure situations, it's not something that it makes any
sense to set directly, as Ben has already shown.
> In my understanding it receives utf-8 textstrings and stores it into
> an non-utf-8 variable that has to be utf-8-tagged by yourself. Isn't
> it?
I thought Ben already addressed that point. Ah, and via googroups I
see that he has already responded, although it hasn't yet reached my
news swerver. So I'll leave it there for now.
------------------------------
Date: 26 Jul 2006 22:24:23 -0700
From: "anju" <go4anju@gmail.com>
Subject: How to use threads to parallelise 4 different DB connections?
Message-Id: <1153977863.425872.266980@b28g2000cwb.googlegroups.com>
Hi ,
My script is making connection to the four databases one by one and
writing the output to a single excelsheet. But there being huge
records, its taking too much time ( 4 hours), which is not acceptable.
So I need to synchronise the process so that the connection is made to
all the 4 DBs at one time and they run parallely.
I tried using Perl threads/ ithreads for the same but its giving
problem, like handles can't be shared , use clone() method etc. etc.
Can you please advice how can I do the same?
Please reply ASAP.
Many Thanks in advance.
Regards,
Anju
------------------------------
Date: Thu, 27 Jul 2006 04:42:06 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Jul 27 2006
Message-Id: <J31p26.3Ms@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.
CGI-Application-Plugin-Authentication-0.11
http://search.cpan.org/~ceeshek/CGI-Application-Plugin-Authentication-0.11/
Authentication framework for CGI::Application
----
CGI-Application-Search-1.01
http://search.cpan.org/~wonko/CGI-Application-Search-1.01/
Base class for CGI::App Swish-e site engines
----
Catalyst-Controller-Constraints-0.10_01
http://search.cpan.org/~phaylon/Catalyst-Controller-Constraints-0.10_01/
Constraint Signatures for Controller Actions
----
Catalyst-Model-DBIC-Schema-0.17_01
http://search.cpan.org/~blblack/Catalyst-Model-DBIC-Schema-0.17_01/
DBIx::Class::Schema Model Class
----
Catalyst-Plugin-AutoTemplate-0.01
http://search.cpan.org/~maxa/Catalyst-Plugin-AutoTemplate-0.01/
Catalyst plugin for automatic discovery of templates
----
DBD-DB2-0.79
http://search.cpan.org/~ibmtordb2/DBD-DB2-0.79/
DataBase Driver for DB2 UDB
----
DBD-DB2-0.79a
http://search.cpan.org/~ibmtordb2/DBD-DB2-0.79a/
DataBase Driver for DB2 UDB
----
DBIx-VersionedSubs-0.01
http://search.cpan.org/~corion/DBIx-VersionedSubs-0.01/
all your code are belong into the DB
----
Data-FormValidator-Constraints-HTTP-0.01
http://search.cpan.org/~adapay/Data-FormValidator-Constraints-HTTP-0.01/
Simple Data::FormValidator constraint methods for checking various HTTP methods.
----
Data-Scroller-1.00
http://search.cpan.org/~benh/Data-Scroller-1.00/
----
Imager-0.53
http://search.cpan.org/~tonyc/Imager-0.53/
Perl extension for Generating 24 bit Images
----
Mail-SpamAssassin-3.1.4
http://search.cpan.org/~felicity/Mail-SpamAssassin-3.1.4/
Spam detector and markup engine
----
Net-Whois-Raw-1.08
http://search.cpan.org/~despair/Net-Whois-Raw-1.08/
Get Whois information for domains
----
Net-Z3950-SimpleServer-1.02
http://search.cpan.org/~mirk/Net-Z3950-SimpleServer-1.02/
Simple Perl API for building Z39.50 servers.
----
OODoc-0.93
http://search.cpan.org/~markov/OODoc-0.93/
object oriented production of code related documentation
----
POE-Filter-IRCD-1.8
http://search.cpan.org/~bingos/POE-Filter-IRCD-1.8/
A POE-based parser for the IRC protocol.
----
Plagger-0.7.5
http://search.cpan.org/~miyagawa/Plagger-0.7.5/
Pluggable RSS/Atom Aggregator
----
Sledge-Plugin-RedirectReferer-0.03
http://search.cpan.org/~nekokak/Sledge-Plugin-RedirectReferer-0.03/
referer redirect plugin for Sledge
----
String-Work-1.10
http://search.cpan.org/~kostya/String-Work-1.10/
Module of work with the string
----
Sub-WrapPackages-1.1
http://search.cpan.org/~dcantrell/Sub-WrapPackages-1.1/
add pre- and post-execution wrappers around all the subroutines in packages or around individual subs
----
TAPx-Parser-0.11
http://search.cpan.org/~ovid/TAPx-Parser-0.11/
Parse TAP output
----
Tripletail-0.11_01
http://search.cpan.org/~mikage/Tripletail-0.11_01/
Tripletail, Framework for Japanese Web Application
----
XML-Compile-0.01
http://search.cpan.org/~markov/XML-Compile-0.01/
Compilation based XML processing
----
XML-Flow-0.81
http://search.cpan.org/~zag/XML-Flow-0.81/
Store (restore) perl data structures in XML stream.
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: Thu, 27 Jul 2006 04:24:27 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Please confirm bug in SHLOMIF > Error-0.17 > Error
Message-Id: <Xns980D43D0631Basu1cornelledu@127.0.0.1>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote in
news:Xns980CF1962A218asu1cornelledu@127.0.0.1:
> "Derek Basch" <dbasch@yahoo.com> wrote in
> news:1153956096.203534.125890@m79g2000cwm.googlegroups.com:
>
>> I was hoping someone could confirm a bug for me.
>
> You have the wrong attitude. You should hope to learn something by
> asking people, instead of wanting to find a bug.
OK, I still stand by my rant, but I did some investigating:
D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error::Simple -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
-text at D:\UseNet\clpmisc\err.pl line 8.
Now, of course, the error message should have been "Oops!".
On the other hand:
D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
Oops!
Hmmmmm ...
Now, Error::Simple overrides Error->new but not Error->throw.
>> 265 sub new {
>> 266 my $self = shift;
>> 267 my $text = "" . shift;
This causes the overloaded stringification operator to be invoked which
adds the "at D:\UseNet\clpmisc\err.pl line 8." at the end of the error
message above.
>> 268 my $value = shift;
>> 269 my(@args) = ();
The problem is, Error::Simple->new ends with:
$self->SUPER::new(-text => $text, @args);
whereas it should be
$self->SUPER::new(-text => $value, @args);
After making that change in Error.pm (v.0.16, line 266):
D:\UseNet\clpmisc> cat err.pl
#!/usr/bin/perl
use strict;
use warnings;
use Error;
throw Error::Simple -text => "Oops!" if 1;
__END__
D:\UseNet\clpmisc> err
Oops! at D:\UseNet\clpmisc\err.pl line 8.
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: Thu, 27 Jul 2006 09:26:44 +0200
From: "Ferry Bolhar" <ferry.bolhar@chello.at>
Subject: pod question
Message-Id: <2282f$44c86ab9$54718838$23608@news.chello.at>
Hi to all,
I have documentation in a format called SDML - as you may guess, related
with HTML, but not the same.
Now I have to translate this documentation in POD format.
Seems not to be a great problem, but the documentation contains some tables
and many footnotes. Does someone have experience how to write this in POD.
There are no POD directives for this, but is there another way?
Many thanks for your help, and kind greetings,
Ferry
------------------------------
Date: 27 Jul 2006 08:39:15 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: pod question
Message-Id: <4ircdjF504puU1@news.dfncis.de>
Ferry Bolhar <ferry.bolhar@chello.at> wrote in comp.lang.perl.misc:
> Hi to all,
>
> I have documentation in a format called SDML - as you may guess, related
> with HTML, but not the same.
>
> Now I have to translate this documentation in POD format.
>
> Seems not to be a great problem, but the documentation contains some tables
> and many footnotes. Does someone have experience how to write this in POD.
> There are no POD directives for this, but is there another way?
There is a POD-compatible something called PseudoPod (used by O'Reilly)
that handles footnotes and some other stuff. I don't know about tables.
There's always verbatim paragraphs.
Anno
------------------------------
Date: Thu, 27 Jul 2006 08:41:58 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Uninitialized value errors
Message-Id: <ea9nav$n61$1@nntp.fujitsu-siemens.com>
axel@white-eagle.invalid.uk wrote:
> Archimede Pitagorico <archimede@linby.net> wrote:
>=20
>>This code give me many errors:
>=20
> =20
>=20
>>http://nopaste.info/6ec866c6ea.html
>=20
> =20
>=20
>>1) Use of uninitialized value in numeric gt (>) ....
>=20
> =20
>=20
>>Why? Thanks.
>=20
>=20
> If you cannot be bothered to actually post your code, why should we
> bother to look it up on the web?
Also, the error message given (omitting the line number) would require=20
us to actually run the script. Running an unknown, and in this case=20
*known* *buggy* script is pretty much like eating something found on the =
sidewalk.
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 27 Jul 2006 08:15:30 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Uninitialized value errors
Message-Id: <4irb12F51uc1U1@news.dfncis.de>
Archimede Pitagorico <archimede@linby.net> wrote in comp.lang.perl.misc:
> This code give me many errors:
>
> http://nopaste.info/6ec866c6ea.html
>
> 1) Use of uninitialized value in numeric gt (>) ....
That's a rather misleading description of your program's behavior.
Why don't you mention the other 13 error messages you're getting?
Why don't you mention that the program asks you to enter two integers
but doesn't give you the chance to do so?
Anno
------------------------------
Date: Thu, 27 Jul 2006 07:06:40 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Using an input/csv file to rename files
Message-Id: <4CZxg.7268$5K2.5062@fed1read03>
Terry <tdcarr@gmail.com> wrote:
> I am a few hours into my life after Perl.
> I need to rename approximately 5000 .jpg files, which I think I have
> figured out thanks to "Learning Perl" 3rd. Ed. (pg. 176).
> Unlike that example, I would like to compare/match the file names to a
> table/field in a csv file and once matched rename the file to the
> second table/field in the csv file so that ABCDEFG.jpg becomes
> 1111111.jpg and ABCDEFH.jpg becomes 1111112.jpg and so on.
> Any suggestions of howto: or where to look would be greatly
> appreciated.
If I understand correctly, you have a CSV file based on two filenames (and
maybe some extra fields?) and need to take your list of filenames, look
up and old name if if in the CSV list, rename it to a new name from the
same record in the CSV list.
Others have mentioned CPAN modules to handle CSV data. Although if
your data are simply filenames separated by a comma with no fields
specified in quotation marks, then it may be easier to simply split
the incoming records... but only if you are totally sure of your data
source.
Whichever method you choose, you can then create a hash based on a key
of the 'old' filename and value of the 'new' filename.
It is then trivial to check incoming filenames to see if they are in the
hash and perform any required renaming, logging and so on.
Axel
------------------------------
Date: Thu, 27 Jul 2006 10:00:05 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: What is the right syntax?
Message-Id: <Xns980D65BDB6C59elhber1lidotechnet@10.232.40.227>
Tad McClellan <tadmc@augustmail.com> wrote:
> Chris Newman <chris-newman@bigpond.com> wrote:
>
>> foreach $i @names {
> ^^^^^^
> ^^^^^^ no parenthesis
>
>> print ("$names[i], $occup[i] \n");
> ^ ^
> ^ ^ no dollar signs
>
> That is not Perl code.
use constant i => 1;
my @array = qw [it sure is];
print $array[i];
;-)
--
Cheers,
Bernard
------------------------------
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 9530
***************************************