[29539] in Perl-Users-Digest
Perl-Users Digest, Issue: 783 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 11:09:49 2007
Date: Wed, 22 Aug 2007 08:09: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 Wed, 22 Aug 2007 Volume: 11 Number: 783
Today's topics:
Can I load a package's Autoload-able subs without execu w.c.humann@arcor.de
Re: FAQ 8.39 How do I set CPU limits? <bik.mido@tiscalinet.it>
Re: how to call sub by value in variable anno4000@radom.zrz.tu-berlin.de
Re: how to call sub by value in variable <yankeeinexile@gmail.com>
new CPAN modules on Wed Aug 22 2007 (Randal Schwartz)
Re: several sockets in the same process (aka ? the Platypus)
Re: SOAP::Lite anno4000@radom.zrz.tu-berlin.de
Re: Stumped: returning a read pipe from a function anno4000@radom.zrz.tu-berlin.de
Re: Stumped: returning a read pipe from a function anno4000@radom.zrz.tu-berlin.de
Re: Symrefs <jurgenex@hotmail.com>
Re: Symrefs <uri@stemsystems.com>
Re: Symrefs <stoupa@practisoft.cz>
Re: Symrefs <jurgenex@hotmail.com>
Re: Symrefs <cwilbur@chromatico.net>
Unexpected 1 in Error File From DBI->connect <bsmith@sudleydeplacespam.com>
Re: Unexpected 1 in Error File From DBI->connect <mritty@gmail.com>
Re: UTF-8 problem <tzz@lifelogs.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Aug 2007 07:21:04 -0700
From: w.c.humann@arcor.de
Subject: Can I load a package's Autoload-able subs without executing them?
Message-Id: <1187792464.140524.169610@i38g2000prf.googlegroups.com>
I want to be able to really load all subs in a given package,
including all load-on-demand subs. I don't want to execute them in the
process. Ideally it should work irrespective of the mechanism (e.g.
AutoLoader, SelfLoader, load-pragma) used inside the module. But the
next best thing would be a solution just for "use AutoLoader"-modules.
I could manually look for ".al"-files and require them but that's not
very elegant as it uses knowledge about internals I shouldn't need to
have.
Why do I want to do this? I'm deriving from Devel::TraceCalls to see
what's going on inside my Perl/Tk application. For a while I wondered
why some functions never got traced. Well, when the tracer is
instantiated they are not there -- they are autoloaded later -- so the
tracer can't wrap them...
Thanks,
Wolfram
------------------------------
Date: Wed, 22 Aug 2007 09:52:33 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: FAQ 8.39 How do I set CPU limits?
Message-Id: <0lqnc3tmbbo9mfqnn5aa8oaq6294uekf2u@4ax.com>
On Tue, 21 Aug 2007 15:34:26 -0700, Bill H <bill@ts1000.us> wrote:
>Could we get a little more detail in these? A cursory (and I do mean
>cursory) look at BSD::Resourse on CPAN gives details on how to
>implement it but really doesnt explain upfront what it will actually
>do. Does it set how much CPU time a program can use, or a percentage
>of usage, or a time period before it will be stopped?
>
>This post is not ment to be a complaint or cause anyone to get upset,
>I just think, since they are aimed at the "newbies" and those like me
>who want to learn more a little more "english" in them would make it
>more helpful.
Just to understand: do you find this to be a charachteristic of this
specific FAQ entry, and possibly of some other, or a general one of
the FAQ. If the former, I *think* that the limits are somewhat
intrinsic of the subject. I *think* that there may be now some other
OS specific modules e.g. in a Linux::* namespace to do similar things,
and so on.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 22 Aug 2007 11:34:21 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: how to call sub by value in variable
Message-Id: <5j2l9tF3sbnr7U1@mid.dfncis.de>
Petr Vileta <stoupa@practisoft.cz> wrote in comp.lang.perl.misc:
> Brian McCauley wrote:
> > On Aug 20, 3:09 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> >> Brian McCauley wrote:
> >>> It's trivial to use CODE symrefs without switching off use strict.
> >>
> >>> (\&$sub)->($name);
> >>
> >> Yippee :-) This is what I looked for.
> >
> > No! Please no! The above code is using symrefs but not _obviously_
> > using symrefs. If you are using symrefs your code should look like it
> > is. The easiest way to do this to put it in a a "no strict 'refs'"
> > block.
>
> Why not? I like not obviously solutions :-) and this is smart and elegant.
"Smart" and "Elegant" are often the arch-enemies of maintainability.
> Of course, no sctrict 'refs' is valid for some block, say while, foreach
> etc., but if I use it then I must not forget to switch strict "on" if I add
> some code in the same block in future. For me is better to not play with
> strict on/off and use this syntax of sub calling.
If there isn't already a convenient block, use a bare block to isolate
"no strict ..."; A decent Perl coder will understand why it's there
and not add random code inside.
Anno
------------------------------
Date: 22 Aug 2007 08:55:16 -0500
From: Lawrence Statton <yankeeinexile@gmail.com>
Subject: Re: how to call sub by value in variable
Message-Id: <878x83ptbv.fsf@hummer.cluon.com>
"Petr Vileta" <stoupa@practisoft.cz> writes:
> Brian McCauley wrote:
> > On Aug 20, 3:09 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> >> Brian McCauley wrote:
> >>> It's trivial to use CODE symrefs without switching off use strict.
> >>
> >>> (\&$sub)->($name);
> >>
> >> Yippee :-) This is what I looked for.
> >
> > No! Please no! The above code is using symrefs but not _obviously_
> > using symrefs. If you are using symrefs your code should look like it
> > is. The easiest way to do this to put it in a a "no strict 'refs'"
> > block.
>
> Why not? I like not obviously solutions :-) and this is smart and
> elegant.
Except for the minor fact that it's stupid and ugly...
> Of course, no sctrict 'refs' is valid for some block, say
> while, foreach etc., but if I use it then I must not forget to switch
> strict "on" if I add some code in the same block in future. For me is
> better to not play with strict on/off and use this syntax of sub
> calling.
This is getting remarkably cargo-cult ... you honestly mean that
sub do_iffy_dispatch {
my $function = shift;
no strict 'refs';
return $function->(@_);
}
is somehow LESS maintainable than jumping through dereference hoops?
To repeat what was said up thread: Once you have elected for good and
sufficient reason to use symrefs, walk up to the counter and in a loud
clear voice say, "Harry, I want you to sell me a condom..." no, wait,
that's a Monty Python sketch, instead you should say, "I have elected
for good and sufficient reason to use symrefs and I am going to flag
that call with a no strict refs to show that I know what I'm doing."
From the tortured metaphor department: If you are going to dig that
pit in the middle of the road, do not disguise it with spread out
newspapers, but but the well known flashing red light of a no strict
next to it, so that your replacement knows what is going on.
--
Lawrence Statton - lawrenabae@abaluon.abaom s/aba/c/g
Computer software consists of only two components: ones and
zeros, in roughly equal proportions. All that is required is to
place them into the correct order.
------------------------------
Date: Wed, 22 Aug 2007 04:42:15 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Aug 22 2007
Message-Id: <Jn5rqF.1I54@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.
Authen-Prepare-0.05
http://search.cpan.org/~dnarayan/Authen-Prepare-0.05/
Prepare a set of authentication credentials
----
Bio-Grep-v0.10.0
http://search.cpan.org/~limaone/Bio-Grep-v0.10.0/
Perl extension for searching in DNA and protein sequences
----
Bio-NEXUS-Import-v0.0.4
http://search.cpan.org/~limaone/Bio-NEXUS-Import-v0.0.4/
Extends Bio::NEXUS with parsers for file formats of popular phylogeny programs
----
Bricklayer-Templater-0.9.4
http://search.cpan.org/~zaphar/Bricklayer-Templater-0.9.4/
yet another templating system. Pure perl, highly flexible with very few dependencies.
----
CGI-Minimal-1.28
http://search.cpan.org/~snowhare/CGI-Minimal-1.28/
A lightweight CGI form processing package
----
CGI-Minimal-1.29
http://search.cpan.org/~snowhare/CGI-Minimal-1.29/
A lightweight CGI form processing package
----
Catalyst-Plugin-ConfigLoader-0.15
http://search.cpan.org/~bricas/Catalyst-Plugin-ConfigLoader-0.15/
Load config files of various types
----
Catalyst-Runtime-5.7009
http://search.cpan.org/~mramberg/Catalyst-Runtime-5.7009/
Catalyst Runtime version
----
Catalyst-View-BK-0.1
http://search.cpan.org/~zaphar/Catalyst-View-BK-0.1/
----
Catalyst-View-BK-0.1a
http://search.cpan.org/~zaphar/Catalyst-View-BK-0.1a/
Catalyst View for Bricklayer::Templater
----
Catalyst-View-Mason-0.13
http://search.cpan.org/~flora/Catalyst-View-Mason-0.13/
Mason View Class
----
Config-INI-0.007
http://search.cpan.org/~rjbs/Config-INI-0.007/
----
Crypt-AllOrNothing-0.09
http://search.cpan.org/~zandet/Crypt-AllOrNothing-0.09/
All-Or-Nothing Encryption
----
Crypt-AllOrNothing-0.10
http://search.cpan.org/~zandet/Crypt-AllOrNothing-0.10/
All-Or-Nothing Encryption
----
Crypt-AllOrNothing-Util-0.09
http://search.cpan.org/~zandet/Crypt-AllOrNothing-Util-0.09/
Util functions for Crypt::AllOrNothing
----
DBIx-DataModel-0.32
http://search.cpan.org/~dami/DBIx-DataModel-0.32/
Classes and UML-style Associations on top of DBI
----
Data-Queue-Persistent-0.09
http://search.cpan.org/~revmischa/Data-Queue-Persistent-0.09/
Perisistent database-backed queue
----
Encode-HanExtra-0.20
http://search.cpan.org/~audreyt/Encode-HanExtra-0.20/
Extra sets of Chinese encodings
----
Encode-HanExtra-0.21
http://search.cpan.org/~audreyt/Encode-HanExtra-0.21/
Extra sets of Chinese encodings
----
File-Copy-Recursive-0.34
http://search.cpan.org/~dmuey/File-Copy-Recursive-0.34/
Perl extension for recursively copying files and directories
----
Games-Worms-0.65
http://search.cpan.org/~avif/Games-Worms-0.65/
alife simulator for Conway/Patterson/Beeler worms, etc.
----
Handel-1.00004
http://search.cpan.org/~claco/Handel-1.00004/
A cart/order/checkout framework with AxKit/TT/Catalyst support
----
IPC-MorseSignals-0.06
http://search.cpan.org/~vpit/IPC-MorseSignals-0.06/
Communicate between processes with Morse signals.
----
JSON-XS-1.44
http://search.cpan.org/~mlehmann/JSON-XS-1.44/
JSON serialising/deserialising, done correctly and fast
----
Lingua-EN-Titlecase-0.04
http://search.cpan.org/~ashley/Lingua-EN-Titlecase-0.04/
Titlecasing of English words by traditional editorial rules.
----
Lingua-EN-Titlecase-0.05
http://search.cpan.org/~ashley/Lingua-EN-Titlecase-0.05/
Titlecasing of English words by traditional editorial rules.
----
Linux-Btldr-Pxelinux-0.21
http://search.cpan.org/~muir/Linux-Btldr-Pxelinux-0.21/
----
OpenGL-Image-1.01
http://search.cpan.org/~bfree/OpenGL-Image-1.01/
copyright 2007 Graphcomp - ALL RIGHTS RESERVED Author: Bob "grafman" Free - grafman@graphcomp.com
----
POE-Component-Win32-ChangeNotify-1.05
http://search.cpan.org/~bingos/POE-Component-Win32-ChangeNotify-1.05/
A POE wrapper around Win32::ChangeNotify.
----
POE-Component-Win32-EventLog-1.09
http://search.cpan.org/~bingos/POE-Component-Win32-EventLog-1.09/
A POE component that provides non-blocking access to Win32::EventLog.
----
POE-Component-Win32-Service-1.06
http://search.cpan.org/~bingos/POE-Component-Win32-Service-1.06/
A POE component that provides non-blocking access to Win32::Service.
----
POE-Component-Win32-Service-1.07
http://search.cpan.org/~bingos/POE-Component-Win32-Service-1.07/
A POE component that provides non-blocking access to Win32::Service.
----
Perl-Critic-1.07
http://search.cpan.org/~elliotjs/Perl-Critic-1.07/
Critique Perl source code for best-practices
----
Perl-Critic-Tics-0.004
http://search.cpan.org/~rjbs/Perl-Critic-Tics-0.004/
policies for things that make me wince
----
Socket-Class-1.0.0
http://search.cpan.org/~chrmue/Socket-Class-1.0.0/
A class to communicate with sockets
----
Template-Plugin-ASCIITable-0.2
http://search.cpan.org/~dakkar/Template-Plugin-ASCIITable-0.2/
----
Test-WWW-Mechanize-Catalyst-0.40
http://search.cpan.org/~lbrocard/Test-WWW-Mechanize-Catalyst-0.40/
Test::WWW::Mechanize for Catalyst
----
Text-Normalize-NACO-0.11
http://search.cpan.org/~bricas/Text-Normalize-NACO-0.11/
Normalize text based on the NACO rules
----
URI-jar-0.01
http://search.cpan.org/~zigorou/URI-jar-0.01/
Java ARchive URI
----
URI-jar-0.02
http://search.cpan.org/~zigorou/URI-jar-0.02/
Java ARchive URI
----
WWW-Search-AltaVista-2.148
http://search.cpan.org/~mthurn/WWW-Search-AltaVista-2.148/
class for searching www.altavista.com
----
WebService-Recruit-HotPepper-0.02
http://search.cpan.org/~bashi/WebService-Recruit-HotPepper-0.02/
perl interface for HotPepper Web Service
----
pfacter-1.8
http://search.cpan.org/~sschneid/pfacter-1.8/
Collect and display facts about the system
----
pler-0.25
http://search.cpan.org/~adamk/pler-0.25/
The DWIM Perl Debugger
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: Wed, 22 Aug 2007 08:55:41 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: several sockets in the same process
Message-Id: <slrnfcnvfp.26q.dformosa@localhost.localdomain>
On Wed, 22 Aug 2007 04:34:09 +0200, Larry <dontmewithme@got.it> wrote:
[...]
> I'm sorry ... I coulda done with telling you what I've been trying to
> do. I want port numbers from 45000 to 65535 to be busy... and I want
> this to work background, so that p2p apps can't be launched as there's
> no free port to bind to...am I crazy?
A better approach would be to use a firewall to prevent packets in
that range from being used.
------------------------------
Date: 22 Aug 2007 08:29:09 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: SOAP::Lite
Message-Id: <5j2aelF3sarcfU1@mid.dfncis.de>
Jorge Reyes <jorg_reyes@hotmail.com> wrote in comp.lang.perl.misc:
> **********
> Excellent, man thanks, now i dont want to be lazzy but can you help to
> understand the next wsdl:
You didn't get that from the code you show below.
> **********
>
> <?xml version="1.0" encoding="UTF-8" ?>
> - <wsdl:definitions targetNamespace="http://
[more xml snipped]
> i do the next perl:
>
> #!C:\Perl\bin\perl -w
> use strict;
> use SOAP::Lite qw;
Xho advised you to add "qw (debug trace)" to the use-statement, you only
added "qw;". That renders the rest of your script useless because qw
will interpret part of your code as data. See "Quote-Like Operators"
in perlop.
> my $soap = SOAP::Lite
> -> uri('http://serviciosweb.remedyweb.iusacell.com')
> -> proxy('http://10.199.11.69:9080/remedyWeb/services/
> ActualizaStatus')
> -> on_action( sub { join '', @_} );
>
> my $s = $soap->paramRemedy("CERRADO",333,"OMAR","FALLITA","5514864823",
> 50)->result;
> print $s;
>
> and gives me the error:
>
> Possible attempt to separate words with commas at wsremedyclient.pl
> line 8.
That's a warning from the erroneous "qw".
> syntax error at wsremedyclient.pl line 10, near "my "
> Execution of wsremedyclient.pl aborted due to compilation errors.
This error turns up only because of the misapplied "qw".
> ******** please its the last favor please
> ****************************
The way it looks, you still have a way to go.
Anno
------------------------------
Date: 22 Aug 2007 13:12:49 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Stumped: returning a read pipe from a function
Message-Id: <5j2r2hF3o4ffsU1@mid.dfncis.de>
<xhoster@gmail.com> wrote in comp.lang.perl.misc:
[...]
> Even if the alternatives besides those two are very rare, do they still
> need to be dealt with? I've often painted myself into a corner by using
> a method that made it easy to deal with 99.99% but then made it nearly
> impossible to deal with the other 0.01%. So now I'm very leery about
> things that look like they are starting down that road.
That is an astute observation. Similar to error handling, ignoring the
0.01% often leads to a simple, clean solution -- that becomes a an utter
mess of spaghetti once you start dealing with the remaining cases. There
ought to be a design pattern for that situation. (There probably is, I
wouldn't know.)
Anno
------------------------------
Date: 22 Aug 2007 13:59:47 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Stumped: returning a read pipe from a function
Message-Id: <5j2tqjF3r4f1eU1@mid.dfncis.de>
<xhoster@gmail.com> wrote in comp.lang.perl.misc:
[...]
> Hmm. That makes me wonder, when you do an ordinary pipe open
> (not IPC::Open? open), the corresponding close automatically waits on the
> child. How does it know what pid to wait on?
It has been my understanding that close() waits for one child to finish,
never mind the PID. That's why specific "waitpid $my_known_pid" doesn't
mix well with system() and friends -- Perl's child handling may have
snatched the PID you're waiting for.
Then again, perldoc -f close is specific:
Closing a pipe also waits for the process executing
on the pipe to complete...
which would be... well, a simplification if my understanding were true.
> The pid must be stored
> somewhere in the resulting file handle, but where? I tried finding it with
> Devel::Peek, but couldn't. Considering my lack of experience with
> Devel::Peek, I guess that that isn't surprising.
Well, there's glob magic involved. If it's hidden there, it wouldn't be
evident from a Devel::Peek::Dump of the file handle. Another (less likely)
possibility would be to associate the PID via the handle's refaddr (inside-
out style). That would leave no traces at all in the file handle.
Anno
------------------------------
Date: Wed, 22 Aug 2007 04:25:10 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Symrefs
Message-Id: <GUOyi.3803$Wr3.2755@trndny03>
Petr Vileta wrote:
> I write web application for collecting weather data for as many
> locations as possible. In internet are many servers with weather
> data. Some personal, some business, some government. On some servers
> you can collect data about tens or hundred towns, on some servers you
> can get data about one location only. Of course, every server
> generate different html code which I must to parse for get data.
> A limited number of people in world have access to my database and
> can to add new link to weather page. The "link" field in database
> have own unique index and cannot be inserted twice. So as you can see
> for some pages the links are similar, say
> http://www.france-weather.fr?town=Paris
> http://www.france-weather.fr?town=Caen
> and I can use the same sub to parse html code. Other links are very
> different and I must use very different subs. I don't know how many
> locations/links I will have in DB next year or in 5 years ;-) And I
> don't know too, how many subs I will have. Maybe links will be 5000
> and subs 100, maybe links will be 5000 and subs 4000.
You just described the perfect scenario for using a dispatch table.
Absolutely no need for messing around with eval() or symrefs or similar
workarounds.
jue
------------------------------
Date: Wed, 22 Aug 2007 04:28:22 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Symrefs
Message-Id: <x7bqd0nqft.fsf@mail.sysarch.com>
>>>>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:
PV> A limited number of people in world have access to my database and can
PV> to add new link to weather page. The "link" field in database have own
PV> unique index and cannot be inserted twice. So as you can see for some
PV> pages the links are similar, say
PV> http://www.france-weather.fr?town=Paris
PV> http://www.france-weather.fr?town=Caen
PV> and I can use the same sub to parse html code. Other links are very
PV> different and I must use very different subs. I don't know how many
PV> locations/links I will have in DB next year or in 5 years ;-) And I
PV> don't know too, how many subs I will have. Maybe links will be 5000 and
PV> subs 100, maybe links will be 5000 and subs 4000.
that still is no excuse to use symrefs. when you write a new parser sub
you can add it to the dispatch table at the same time. it isn't extra
work. and a dispatch table will make it easier to map 100 subs to 5000
sites by the key names in the db. you can even make the key names
reflect the actual site name and the sub name reflect the style of
parsing. then the dispatch table is mapping many sites to fewer parse
subs. this way the db names are tied to the actual site which make it
easier to manage that.
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: Wed, 22 Aug 2007 07:05:05 +0200
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Symrefs
Message-Id: <faggc2$jbt$1@ns.felk.cvut.cz>
Jürgen Exner wrote:
> Petr Vileta wrote:
>> http://www.france-weather.fr?town=Paris
>> http://www.france-weather.fr?town=Caen
>> and I can use the same sub to parse html code. Other links are very
>> different and I must use very different subs. I don't know how many
>> locations/links I will have in DB next year or in 5 years ;-) And I
>> don't know too, how many subs I will have. Maybe links will be 5000
>> and subs 100, maybe links will be 5000 and subs 4000.
>
> You just described the perfect scenario for using a dispatch table.
> Absolutely no need for messing around with eval() or symrefs or
> similar workarounds.
>
Good haevens! :-) Dispatch table with 4000 entries? And manually update it?
No, thanks ;-)
When the sub name will be say 8 characters only + 2 characters => then it
means 40000 characters of needless code. For me is better to write 2 rows of
code to do script self-check.
# $parser contain sub's name
if(defined(&{"main::" . $parser})) { (\&$parser)->($parameter); }
else { warn "Sub $parser not exist\n"; }
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)
------------------------------
Date: Wed, 22 Aug 2007 12:53:07 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Symrefs
Message-Id: <TkWyi.4316$nB3.1898@trndny02>
Petr Vileta wrote:
> Jürgen Exner wrote:
>> Petr Vileta wrote:
>>> http://www.france-weather.fr?town=Paris
>>> http://www.france-weather.fr?town=Caen
>>> and I can use the same sub to parse html code. Other links are very
>>> different and I must use very different subs. I don't know how many
>>> locations/links I will have in DB next year or in 5 years ;-) And I
>>> don't know too, how many subs I will have. Maybe links will be 5000
>>> and subs 100, maybe links will be 5000 and subs 4000.
>>
>> You just described the perfect scenario for using a dispatch table.
>> Absolutely no need for messing around with eval() or symrefs or
>> similar workarounds.
>>
> Good haevens! :-) Dispatch table with 4000 entries? And manually
> update it? No, thanks ;-)
Don't you think that in particular in a case like this an additional
abstraction layer would be very convenient?
Then the person who enters the data in the DB can use a meaningful name
without the need to know how the subs are named in your program.
> When the sub name will be say 8 characters only + 2 characters => then it
> means 40000 characters of needless code.
How many characters to you expect your subs to be on average? Maybe 15 lines
of 30 characters each (just a guess, but I think in reality it will be
significantly larger)? Then we are talking about an increase in code size of
less than 3%.
To me a better architecture and cleaner code is well worth those additional
3%.
> For me is better to write 2 rows of code to do script self-check.
Suit yourself.
jue
------------------------------
Date: 22 Aug 2007 09:56:14 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Symrefs
Message-Id: <87odgz4qrl.fsf@mithril.chromatico.net>
>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
JE> The total lack of differentiation between code and data makes
JE> for some very nice features like HOFs, closures, and
JE> others. But face it, LISP is almost 50 years old and many of
JE> its design features are shall we say not quite up to date with
JE> modern principles of programming language design.
Huh?! Lisp has a history going back 50 years, but Lisp itself was
standardized in the mid-80s, roughly the same vintage as C. And most
of its design features were years ahead of their time....
I recommend that you take a serious look at Lisp before saying things
like this -- it's roughly analogous to saying "Perl? Oh, that's only
good for web scripting." It's a similar sort of misconception, and
just as wrong.
Charlton
--
Charlton Wilbur
cwilbur@chromatico.net
------------------------------
Date: Wed, 22 Aug 2007 14:04:01 GMT
From: Bob Smith <bsmith@sudleydeplacespam.com>
Subject: Unexpected 1 in Error File From DBI->connect
Message-Id: <lnXyi.14448$B25.12261@news01.roc.ny>
Using perl 5.8.7 and DBI 1.53 on a Linux system, the following
function outputs a spurious "1" to the web server's error file on the
DBI->connect line:
sub DBConnect
{
my ($DataBase) = @_;
my $DSN_SFS = "DBI:mysql:$DataBase"; # Data Source Name
my $DSN_USER = "root"; # ... (user name)
my $DSN_PWD = "secret"; # ... (password)
my %attr = (PrintError => 0, ## Don't report errors via warn ()
RaiseError => 0 ## Don't report errors via die ()
);
$dbh = DBI->connect ($DSN_SFS, $DSN_USER, $DSN_PWD, \%attr) or die
print "Can't open database <$DSN_SFS>"
. "<br />$DBI::errstr";
return $dbh;
}
Otherwise, the function works just fine. Any ideas on what could be
triggering the spurious output?
--
_________________________________________
Bob Smith -- bsmith@sudleydeplacespam.com
To reply to me directly, delete "despam".
------------------------------
Date: Wed, 22 Aug 2007 07:12:55 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: Unexpected 1 in Error File From DBI->connect
Message-Id: <1187791975.653970.134470@i38g2000prf.googlegroups.com>
On Aug 22, 10:04 am, Bob Smith <bsm...@sudleydeplacespam.com> wrote:
> Using perl 5.8.7 and DBI 1.53 on a Linux system, the following
> function outputs a spurious "1" to the web server's error file
> on the DBI->connect line:
>
> sub DBConnect
> {
> my ($DataBase) = @_;
> my $DSN_SFS = "DBI:mysql:$DataBase"; # Data Source Name
> my $DSN_USER = "root"; # ... (user name)
> my $DSN_PWD = "secret"; # ... (password)
>
> my %attr = (PrintError => 0, ## Don't report errors via warn ()
> RaiseError => 0 ## Don't report errors via die ()
> );
> $dbh = DBI->connect ($DSN_SFS, $DSN_USER, $DSN_PWD, \%attr) or die
> print "Can't open database <$DSN_SFS>"
> . "<br />$DBI::errstr";
> return $dbh;
>
> }
>
> Otherwise, the function works just fine. Any ideas on what
> could be triggering the spurious output?
die() takes a string to print to STDERR and exits the program.
print() takes a string to print to STDOUT and returns 1 if successful.
die(print("whatever"));
will therefore print "whatever" to STDOUT, and return 1 to die().
die() will then print 1 to STDERR and exit the program.
Change die(print("whatever")) to die("whatever");
Paul Lalli
------------------------------
Date: Wed, 22 Aug 2007 09:11:12 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: UTF-8 problem
Message-Id: <m2fy2b4q2n.fsf@lifelogs.com>
On Wed, 22 Aug 2007 00:23:17 +0200 Todor Vachkov <vachkov@math.tu-berlin.de> wrote:
TV> Hello all,
TV> I'm trying to convert an exported xml file into a perl data structre with the XML::LibXML modul.
TV> Thus I got this error message:
>> Entity: line 315442: parser error : Input is not proper UTF-8, indicate
>> encoding !
>> Bytes: 0xE2 0x26 0x6C 0x74
TV> I thought the solution would be:
>> open(my $fh, "< :encoding(utf8)" ,'/foodir/export.xml');
>> my $parser = XML::LibXML->new();
>> my $dom = $parser->parse_fh($fh);
>> my $root = $dom->getDocumentElement;
TV> but this produce a long long list (maybe for each parsed character in the xml file) of error messages :
>> utf8 "\xE2" does not map to Unicode at /perlmodules/lib/i586-linux-thread-multi/XML/LibXML.pm line 429.
TV> .
TV> .
TV> .
>> utf8 "\xE4" does not map to Unicode >at /perlmodules/lib/i586-linux-thread-multi/XML/LibXML.pm line 429.
>> Segmentation fault
TV> The segmentaion fail always at the same \xE4 character, but it's a secondary problem.
TV> I just want to let the modul to parse the xml file, which is really large (over 20MB)
TV> and has being exported from another software. Thus I haven't any influence what comes into it.
Can you post with the first 50 lines of the file, or put up a smaller
complete version of it online somewhere we can examine it? Your post
doesn't help at all with finding the problem (we can only guess that
your input file is not valid).
Ted
------------------------------
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 783
**************************************