[28632] in Perl-Users-Digest
Perl-Users Digest, Issue: 9996 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 22 09:06:05 2006
Date: Wed, 22 Nov 2006 06:05:07 -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 Wed, 22 Nov 2006 Volume: 10 Number: 9996
Today's topics:
Re: accessing numeric variables from textfield input in rallabs@adelphia.net
Re: Can perl create process or thread to do things conc <mritty@gmail.com>
Re: Do I *have* to use 'OOP' to use modules? <abigail@abigail.be>
Re: Do I *have* to use 'OOP' to use modules? <nospam-abuse@ilyaz.org>
Re: Do I *have* to use 'OOP' to use modules? <phaylon@dunkelheit.at>
Re: DOS-Box script is running in set always on top <john@castleamber.com>
Embedding perl in shared libs <usenet-nov-06@bastian-friedrich.de>
Extracting Date using Regular Expressions <shafa.fahad@gmail.com>
Re: Extracting Date using Regular Expressions <someone@example.com>
Re: FAQ 6.19 What good is "\G" in a regular expression? <rvtol+news@isolution.nl>
Re: generic increment of number/string <alexxx.magni@gmail.com>
Re: generic increment of number/string <mritty@gmail.com>
Re: generic increment of number/string <alexxx.magni@gmail.com>
Re: How to change Perl's concept of a newline in regexp <rkrause@searstower.org>
Re: How to change Perl's concept of a newline in regexp <rkrause@searstower.org>
Re: How to change Perl's concept of a newline in regexp <nospam-abuse@ilyaz.org>
Re: How to change Perl's concept of a newline in regexp <rvtol+news@isolution.nl>
How to read the Doctype Information out of an XML File pod69@gmx.net
Re: mysql connection failing as CGI <antispam@randometry.com>
Re: mysql connection failing as CGI ianatkinsonbsc@gmail.com
new CPAN modules on Wed Nov 22 2006 (Randal Schwartz)
Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <matteo_vitturi@virgilio.it>
Re: Perl substitution working on some machines but not <rvtol+news@isolution.nl>
Re: use print to write binary data to a filehandle seem <john@castleamber.com>
Re: use print to write binary data to a filehandle seem <mritty@gmail.com>
Re: use print to write binary data to a filehandle seem quakewang@mail.whut.edu.cn
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 22 Nov 2006 04:18:07 -0800
From: rallabs@adelphia.net
Subject: Re: accessing numeric variables from textfield input in a form
Message-Id: <1164197887.013125.19260@f16g2000cwb.googlegroups.com>
attn.steven.kuo@gmail.com wrote:
Was param($s) the integer you wanted?
--
Hope this helps,
Steven
Steven, Thanks very much, it DID help. Your insight helped me analyze
the situation in a more logical and sane way. I now realize that the
root of my problem is the necessity to use param() without any
arguments. This is because I haven't any idea how many textfields will
be presented for parsing. (my post contained a form with 2 textfields
only, but that's an oversimplification of the real situation, in which
the form presents as little as 1 and as many as 9 textfields.) When
one uses param with no arguments, one gets the NAMES of the textfields,
not their contents. The problem is how to get the contents. The
following is what I tried. Basically, I filled an array with the names
of the textfields and then tried to use param on each array element in
turn. I don't understand why it doesn't work, but I at least
understand why I was getting the error log msg. Here's the guts of my
script 'parse.cgi':
if (param()){
my @Parray=param();#these are the contents of textboxes in submitting
form, 1-9 of them
my $lenparr=scalar(@Parray);
print $cc->h2("The number of elements in \@Parray is $lenparr. \n");
foreach (0..$#Parray) {
print $cc->h3("\$Parray[$_] is $Parray[$_]. Content of checkbox#$_ is
param($Parray[$_]).\n");
}
The last operation, param($Parray[$_]) , does not yield the contents of
$Parray[$_], but rather the words " param(side[N] " for pass "N" thru
the foreach. Yukk. Thank you very much for the help.
Mike
> rallabs@adelphia.net wrote:
>
> (snipped)
>
> > two
> > messages appear in the error log, saying: "$side[0] not numeric in line
> > 25" and "$side[1] not numeric in line 25".
>
> (snipped)
>
>
> > and the second script ('findhyp.cgi') is:
> > #!/usr/bin/perl -wT
> > #This is findhyp.cgi
> > use strict;
> > use warnings;
> > use CGI qw(:standard);
> > $CGI::DISABLE_UPLOADS=1;
> > $CGI::POST_MAX = 102_400; #100KB
> > my $cc = new CGI;
> > print $cc->header;
> > print $cc->start_html(-title=>'findhyp');
> > my @percentS;
> > my $sumsq=0.0;
> > if (param()){
> > my @param=param();#these are the two numbers from textboxes on previous
> > page
> > foreach my $s (param () ) {
> > my $ss=param($s);
> > print $cc->h2("The variable \$s is $ss\n");
> > $sumsq=$sumsq + param($s)*param($s); #sums up squares of two sides
> > }
> > my $squirt=sqrt($sumsq);
> > print $cc->h2("The variable \$sumsq is $sumsq\n");
> > print $cc->h2("The variable \$squirt is $squirt\n");
> > foreach my $s ( param() ) {
> > my $pcnt=0+param($s);# this is supposed to make the $pcnt variable
> > numeric according to Castro p24
> > $percentS[$s] =$pcnt; #we're getting 2 messages in the errorlog saying
> > "$side[n] not numeric in line 25"; one for each pass thru the foreach
>
>
> You need an integer index to access a particular
> element of the array @percentS. The value in
> your $s variable is not an integer.
>
> Was param($s) the integer you wanted?
> If so, try:
>
> $percentS[ param($s) ] = $pcnt;
>
> instead of
>
> $percentS[ $s ] = $pcnt;
>
> --
> Hope this helps,
> Steven
------------------------------
Date: 22 Nov 2006 05:02:56 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Can perl create process or thread to do things concurrently?
Message-Id: <1164200575.965925.278670@j44g2000cwa.googlegroups.com>
quakewang@mail.whut.edu.cn wrote:
> Can perl create process or thread to do things concurrently?
>
> like "fork"?
>
> seems the <<camel book>> did not say about it.
Your copy camel book seems severely buggy. Mine has quite a bit of
information on both. Did you even bother to look in the index for
"fork" or "thread"? Mine says that threads are discussed from pages
446-463, and fork on pages 428, 715, and 989 (not to mention a host of
sub-topics).
Paul Lalli
------------------------------
Date: 22 Nov 2006 06:26:56 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <slrnem7rcb.c8.abigail@alexandra.abigail.be>
Ilya Zakharevich (nospam-abuse@ilyaz.org) wrote on MMMMDCCCXXXI September
MCMXCIII in <URL:news:ek0aed$275m$1@agate.berkeley.edu>:
.. [A complimentary Cc of this posting was sent to
.. Abigail
.. <abigail@abigail.be>], who wrote in article <slrnem6r08.c8.abigail@alexandra.abigail.be>:
.. > Ilya Zakharevich (nospam-abuse@ilyaz.org) wrote on MMMMDCCCXXX September
.. > MCMXCIII in <URL:news:ejvdjb$1hqg$1@agate.berkeley.edu>:
.. > ''
.. > '' Thinking about it a little bit more, I see absolutely no reason to
.. > '' have attributes in the language proper. What is lost if all one has
.. > '' is a module `attr' with methods:
.. >
.. > Usability.
..
.. Could you be more explicit, please?
..
.. Or do you suggest that
..
.. $val = $obj--->>>{a_name}; # Or whatever the syntax is
..
.. is *undisputably* preferable to
..
.. $val = $obj->__get_a_name;
No.
But I do think that
$val = $.a_name;
(to borrow a Perl6 syntax) is vastly superiour over either
$val = $self -> __get_a_name;
and
$val = $$self {a_name};
Abigail
--
# Perl 5.6.0 broke this.
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi
------------------------------
Date: Wed, 22 Nov 2006 08:16:17 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <ek110h$2n6d$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Abigail
<abigail@abigail.be>], who wrote in article <slrnem7rcb.c8.abigail@alexandra.abigail.be>:
> .. Or do you suggest that
> ..
> .. $val = $obj--->>>{a_name}; # Or whatever the syntax is
> ..
> .. is *undisputably* preferable to
> ..
> .. $val = $obj->__get_a_name;
> No.
> But I do think that
>
> $val = $.a_name;
>
> (to borrow a Perl6 syntax) is vastly superiour over either
>
> $val = $self -> __get_a_name;
Enough to influence a choice between languages?
Thanks,
Ilya
------------------------------
Date: 22 Nov 2006 12:25:37 GMT
From: Robert 'phaylon' Sedlacek <phaylon@dunkelheit.at>
Subject: Re: Do I *have* to use 'OOP' to use modules?
Message-Id: <456441c1$0$27624$9b4e6d93@newsspool2.arcor-online.net>
Abigail <abigail@abigail.be> wrote
> Usability.
>
> If Larry had decided that Perl wouldn't have variables, but instead
> functions 'set' and 'get', we could do the same in Perl as we can now.
This sounds a lot like you want Perl to behave like some other
languages. Ruby or Java perhaps? Personally, I'd hate if Perl would
introduce one way to handle attributes. I'm rather glad that I can use
Class::BuildMethods, Moose, Class::Accessor::Fast, or my own
implementation easily in my objects. Sure Perl 6 will have attributes in
a fixed design. But without Perl 5's flexibility over 10 years, how
would they have found what's best for most of us?
Nothing in Perl 5's OO is ill-implemented. It can only be ill if you
make a comparison and set an other language in the position of "right."
And in the end, it *is* just a personal opinion.
gr.,
Robert
--
bellum omnium pater.
------------------------------
Date: 22 Nov 2006 07:04:34 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: DOS-Box script is running in set always on top
Message-Id: <Xns9883AF23564castleamber@130.133.1.4>
l v <veatchla@yahoo.com> wrote:
> Sure it would. But then companies like Actual Tools couldn't sell their
> product. :)
There is a focus follows mouse power toy from Microsoft, for free, which
probably does the same. I never understood why the window with focus has
to pop to the front anyway.
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: Wed, 22 Nov 2006 08:53:33 +0100
From: Bastian Friedrich <usenet-nov-06@bastian-friedrich.de>
Subject: Embedding perl in shared libs
Message-Id: <456401fe$0$27611$9b4e6d93@newsspool2.arcor-online.net>
Hi,
I am currently working on a project that uses the "perlembed" methods to run
perl functions from within a C program. The structure is similar to
Apache's "mod_perl":
Program A loads my library B with the "dlopen" POSIX system call. Library B
is linked against Perl (-lperl /path/to/Dynaloader.a). Library B
initializes a Perl interpreter C that parses a script D. In this script,
there are "use" statements for modules that in turn need binary extensions.
Perl itself uses the "dlopen" call itself to load these extensions.
dlopen takes two parameters: file path, and flags.
* When the first dlopen call (A -> B) is done _without_ "RTLD_GLOBAL"
flag, a segfault occurs during the parsing of the script.
* When linking program A with perl, everything is fine
* When using the RTLD_GLOBAL flag, everything is fine
* When script D does not load binary extensions, everything is fine.
* When statically linking library B to program A (instead of dlopening it),
everything is fine.
Obviously, there is some problem with the dlopen calls :((
If you are interested in the topic, you can download a sample program from
http://www.iump.de/perl_via_dlopen.tar.gz
So my questions are:
* Is this behaviour "normal"? Is RTLD_GLOBAL in fact absolutely necessary in
that place?
* Did I really hit a perl bug??
* Do you know about any workarounds?
Thanks a lot, Regards,
Bastian
------------------------------
Date: 22 Nov 2006 04:04:39 -0800
From: "Kimi" <shafa.fahad@gmail.com>
Subject: Extracting Date using Regular Expressions
Message-Id: <1164197079.928548.190110@h54g2000cwb.googlegroups.com>
Hi I am new to perl,
I need some help in regular expressions....
I have a string "Tue Nov 7 14:04:16 2006: Unable to open prev pos
file" in a variable "myvariable" and I need to extract "Tue Nov 7
14:14:16 2006" to another variable..
I also would like to know if there are any way to compare the above
result with Current date and find the difference of days/months
Appreciate your help,
Kimi
------------------------------
Date: Wed, 22 Nov 2006 13:52:16 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Extracting Date using Regular Expressions
Message-Id: <kCY8h.19532$gy2.4814@edtnps90>
Kimi wrote:
> Hi I am new to perl,
>
> I need some help in regular expressions....
>
> I have a string "Tue Nov 7 14:04:16 2006: Unable to open prev pos
> file" in a variable "myvariable" and I need to extract "Tue Nov 7
> 14:14:16 2006" to another variable..
>
> I also would like to know if there are any way to compare the above
> result with Current date and find the difference of days/months
$ perl -le'
use POSIX q/mktime/;
my $myvariable = "Tue Nov 7 14:04:16 2006: Unable to open prev pos file";
my $week_day = qr/Mon|Tue|Wed|Thu|Fri|Sat|Sun/;
my $mon_name = qr/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/;
my ( $mon, $day, $hour, $min, $sec, $year ) = $myvariable =~ /$week_day \s+
($mon_name) \s+ (\d+) \s+ (\d+) : (\d+) : (\d+) \s+ (\d+)/x;
print "$sec, $min, $hour, $day, $mon, $year";
my $old_date = mktime $sec, $min, $hour, $day, ( index( $mon_name, $mon ) -
index( $mon_name, q/Jan/ ) ) / 4, $year - 1900;
my $current_date = time;
my ( $diff_days, $diff_mons ) = ( gmtime $current_date - $old_date )[ 3, 4 ];
print for scalar localtime $old_date, scalar localtime $current_date, "Days:
$diff_days, Months: $diff_mons";
'
16, 04, 14, 7, Nov, 2006
Tue Nov 7 14:04:16 2006
Wed Nov 22 05:48:51 2006
Days: 15, Months: 0
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
Date: Wed, 22 Nov 2006 11:08:52 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: FAQ 6.19 What good is "\G" in a regular expression?
Message-Id: <ek1b8j.k0.1@news.isolution.nl>
PerlFAQ Server schreef:
> Suppose you want to match all of consective pairs of digits in a
consecutive
> pos()) even if a match on the same string as failed in the
has failed
Where is the c-flag (or should it be called the c-modifier) documented?
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 22 Nov 2006 02:32:19 -0800
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: generic increment of number/string
Message-Id: <1164191539.809027.325330@h48g2000cwc.googlegroups.com>
thanks!
What I had problem with, was that at first I checked on the command
line,
and there I discovered what still puzzles me:
1) output of your program in a script:
0001
0002
0003
...
2) while instead, perl -e 'for my $num ('0001' .. '0100') {print
"$num\n";}' gives:
1
2
3
...
I really wonder why............
Alessandro
Paul Lalli ha scritto:
> alexxx.magni@gmail.com wrote:
> > hi everybody,
> > there is some way to easily loop a padded variable, getting:
> > 0001
> > 0002
> > 0003
> > 0004
> > ...
> >
> > ?
> >
> > I'd like to do it in a simple for() loop, and I wanted to avoid
> > checking the total string length...
>
> You've made it more difficult than it is, probably by thinking too much
> like a C programmer. :-)
>
> for my $num ('0001' .. '0100') {
> print "$num\n";
> }
>
> Paul Lalli
------------------------------
Date: 22 Nov 2006 03:46:37 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: generic increment of number/string
Message-Id: <1164195997.759310.318290@m7g2000cwm.googlegroups.com>
alexxx.magni@gmail.com wrote:
> What I had problem with, was that at first I checked on the command line,
> and there I discovered what still puzzles me:
>
> 1) output of your program in a script:
> 0001
> 0002
> 0003
> ...
>
> 2) while instead, perl -e 'for my $num ('0001' .. '0100') {print
> "$num\n";}' gives:
> 1
> 2
> 3
> ...
Did you actually look at the *entire* list, not just the first three?
It only goes up to 64, not 100. That's because you're using single
quotes within the program, and as delimeters to the perl -e.
Therefore, Perl is not seeing single quoted strings. Instead, Perl is
seeing the shell's interpretation of 0001 and 0100, which are octal 1
and octal 64, respectively.
Change the inner single quotes to double quotes, and everything will
work out...
Paul Lalli
------------------------------
Date: 22 Nov 2006 04:47:39 -0800
From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
Subject: Re: generic increment of number/string
Message-Id: <1164199659.648920.209380@e3g2000cwe.googlegroups.com>
that was tricky!
thanks...............
Alessandro
Paul Lalli ha scritto:
> alexxx.magni@gmail.com wrote:
> > What I had problem with, was that at first I checked on the command line,
> > and there I discovered what still puzzles me:
> >
> > 1) output of your program in a script:
> > 0001
> > 0002
> > 0003
> > ...
> >
> > 2) while instead, perl -e 'for my $num ('0001' .. '0100') {print
> > "$num\n";}' gives:
> > 1
> > 2
> > 3
> > ...
>
> Did you actually look at the *entire* list, not just the first three?
> It only goes up to 64, not 100. That's because you're using single
> quotes within the program, and as delimeters to the perl -e.
> Therefore, Perl is not seeing single quoted strings. Instead, Perl is
> seeing the shell's interpretation of 0001 and 0100, which are octal 1
> and octal 64, respectively.
>
> Change the inner single quotes to double quotes, and everything will
> work out...
>
> Paul Lalli
------------------------------
Date: 21 Nov 2006 22:59:23 -0800
From: "R Krause" <rkrause@searstower.org>
Subject: Re: How to change Perl's concept of a newline in regexps?
Message-Id: <1164178763.864338.248470@h54g2000cwb.googlegroups.com>
Ilya Zakharevich wrote:
> [A complimentary Cc of this posting was sent to
> R Krause
> <rkrause@searstower.org>], who wrote in article <1164035405.224078.19860@m7g2000cwm.googlegroups.com>:
> > Thanks. It's mostly theoretical. After all '$' and '^' and '\Z' do
> > exist for convenience as you've shown in the hint above. I was testing
> > my code and it occured to me that this behavior cannot be changed. As
> > far as being optimal, it is curious why Perl has certain predefined
> > variables that can be changed at all since, to be fair, programmers
> > should never have to modify '$/', '$\', or '$,' to perform any I/O
> > operations. Yet, they exist for efficiency when needed.
>
> I think you are wrong. They exist mostly for backward compatibility.
> These stuff should be made in channels, not in an interpreter.
I'm not certain what channels have to do with Perl's predefined
variables. If in truth '$/', '$\' and so on exist for backwards
compatibility, then I am curious why that is not mentioned in the perl
docs. It seems these variables were introduced by Larry Wall for some
ultimate purpose. If they are now to be disused, than the interpreter
must be dragging around a lot legacy coding.
--Randall
------------------------------
Date: 22 Nov 2006 00:01:03 -0800
From: "R Krause" <rkrause@searstower.org>
Subject: Re: How to change Perl's concept of a newline in regexps?
Message-Id: <1164182462.899539.148640@b28g2000cwb.googlegroups.com>
Dr.Ruud wrote:
> R Krause schreef:
>
> > I know that $/ is the input record separator. But that doesn't seem to
> > affect any change in the behavior of regular expressions in normal and
> > multi-line mode.
>
> That is the wrong way around. When (line oriented) input is read, and
> the proper IO-layer is used, the resulting string will have a "\n" at
> the end.
> See also Encode::Encoding. Compare the :crlf layer.
Thanks. I've checked the :crlf layer but it seems to only work with
overall reading or writing operations and does not affect Perl's
internal processing of specific regexps (esp. in multi-line mode). In
cases of network communications, it is often valuable to test some
portion of input presuming line-delimiters such as '\r\n' or even '\0'
using regular expressions, but to then leave other portions of the
transmission unchanged.
I'm still looking into Encode::Encoding, but that module seems very
complex just for processing text with alternate line-delimiters. :) I
guess the convenience of $ and ^ is lost in this situation, so one
needs to just roll his own.
--Randall
------------------------------
Date: Wed, 22 Nov 2006 08:18:31 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to change Perl's concept of a newline in regexps?
Message-Id: <ek114n$2naf$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
R Krause
<rkrause@searstower.org>], who wrote in article <1164178763.864338.248470@h54g2000cwb.googlegroups.com>:
> > I think you are wrong. They exist mostly for backward compatibility.
> > These stuff should be made in channels, not in an interpreter.
>
> I'm not certain what channels have to do with Perl's predefined
> variables.
Most variables predate objects and channels. Channels (should) make
them obsolete.
> If in truth '$/', '$\' and so on exist for backwards
> compatibility, then I am curious why that is not mentioned in the perl
> docs. It seems these variables were introduced by Larry Wall for some
> ultimate purpose.
Yes - 20 years ago.
> If they are now to be disused, than the interpreter
> must be dragging around a lot legacy coding.
It does.
Hope this helps,
Ilya
------------------------------
Date: Wed, 22 Nov 2006 11:26:57 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to change Perl's concept of a newline in regexps?
Message-Id: <ek1ce9.tc.1@news.isolution.nl>
R Krause schreef:
> Dr.Ruud:
>> R Krause:
>>> I know that $/ is the input record separator. But that doesn't seem
>>> to affect any change in the behavior of regular expressions in
>>> normal and multi-line mode.
>>
>> That is the wrong way around. When (line oriented) input is read, and
>> the proper IO-layer is used, the resulting string will have a "\n" at
>> the end.
>> See also Encode::Encoding. Compare the :crlf layer.
>
> Thanks. I've checked the :crlf layer but it seems to only work with
> overall reading or writing operations and does not affect Perl's
> internal processing of specific regexps (esp. in multi-line mode).
The :crlf layer normalizes the data, so that you don't need to use \r\n
in your code (regexp or not) if your text file happens to be one with
CRLF line endings.
Maybe there exists a :cr layer for Mac-type text files?
> In
> cases of network communications, it is often valuable to test some
> portion of input presuming line-delimiters such as '\r\n' or even '\0'
> using regular expressions, but to then leave other portions of the
> transmission unchanged.
Of course, but make a distinction between platform-dependant line
oriented operations, and buffer oriented operations.
> I'm still looking into Encode::Encoding, but that module seems very
> complex just for processing text with alternate line-delimiters. :) I
> guess the convenience of $ and ^ is lost in this situation, so one
> needs to just roll his own.
If you are not reading the data in a line-oriented way, than just use \r
(or \x0D) etc. You can make your own zero-width assertions like (?=\r).
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 22 Nov 2006 01:04:53 -0800
From: pod69@gmx.net
Subject: How to read the Doctype Information out of an XML File
Message-Id: <1164186293.427436.100600@e3g2000cwe.googlegroups.com>
Hello,
How can i read the Doctype Information out of an xml file?
<!DOCTYPE foo SYSTEM "foo.dtd"
[
<!ENTITY bla SYSTEM "bla.xml">
<!ENTITY foofoo SYSTEM "foofoo.xml">
]
So that i get out e.g. in an array bla.xml and foofoo.xml?
Has someone an example? That would help me a lot!
thx p=E4ttr
------------------------------
Date: Wed, 22 Nov 2006 11:22:47 +0100
From: Ric <antispam@randometry.com>
Subject: Re: mysql connection failing as CGI
Message-Id: <ek18dn$a8p$1@online.de>
ianatkinsonbsc@gmail.com schrieb:
> Hi,
>
> I have a strange problem and I'm hoping someone can help. I've bought
> some new hosting which comes with a MySQL database but I'm struggling
> to get it working with any perl scripts; the hosting support are being
> no help so I've had to come here, sorry guys!
>
> The problem basically is that when the script is run as a CGI script it
> won't connect to the database, however if I run the same script from
> the command line (I have SSH access to the server) it runs fine.
>
Can you check apache log?
tail -f /var/log/http/error_log
you may find the apache log somewhere else depending on your OS.
In addition to that I would use eval to find out what went wrong, see below
> The script is as follows (very simple):
>
> --------------------------------------------------
>
> #! /usr/bin/perl
>
> use DBI;
>
> print "Content-type: text/html\n\n";
> print "<html><head></head><body>\n\nres:\n\n";
>
my $SQL;
my $dbh;
my $sth;
eval{
$dbh =
DBI->connect("DBI:mysql:dbname:mydbname;host=213.171.218.249;port=3306",
"dbuser","dbpass",
{
RaiseError => 1
}
);
>
> $SQL = "SELECT * FROM numbers";
>
> $sth = $dbh->prepare($SQL);
> $sth->execute();
};
if($@){
print $@;
}
> while (@row = $sth->fetchrow_array) { print @row; print "\n"; }
> print "</body></html>";
>
> --------------------------------------------------
>
> And if I run it from the command line:
>
> [domain1201232@ssh5 cgi-bin]$ perl numbers.pl
> Content-type: text/html
>
> <html><head></head><body>
>
> res:
>
> 1
> 10
> 15
> </body></html>
>
> As you can see it connects to the database and retrieves the 3 ints sat
> in there. If I run this from the CGI-bin however the only code output
> is:
>
> <html><head></head><body>
>
> res:
>
> i.e. the script falls over when it tries to make the database
> connection and goes no further.
>
> The hosting support are saying that I have not formed the connection
> string properly, however if that was the case it wouldn't work from the
> command line surely? I have also copied the script over to my machine
> at home (verbatim and connecting to the same MySQL server) and it runs
> fine from there also.
>
> It seems to me like they have a firewalling problem maybe but I don't
> have access to the Apache logs so I'm at a loss as to what else I can
> try really. I did try the same thing in PHP (just using PHP syntax) and
> that works OK, both on the command line and over the web which was
> bringing me back round to the idea that it's a Perl problem, but I
> really can't see anything wrong with it and if the syntax was wrong
> it'd surely crap out on the command line as well!
>
> Any ideas?
>
> Thanks,
>
> Ian.
>
------------------------------
Date: 22 Nov 2006 03:41:54 -0800
From: ianatkinsonbsc@gmail.com
Subject: Re: mysql connection failing as CGI
Message-Id: <1164195714.501599.215260@h48g2000cwc.googlegroups.com>
Ric wrote:
> Can you check apache log?
>
> tail -f /var/log/http/error_log
>
> you may find the apache log somewhere else depending on your OS.
> In addition to that I would use eval to find out what went wrong, see below
Sadly I can't, they have it readable only by root :(
> eval{
> $dbh =
> DBI->connect("DBI:mysql:dbname:mydbname;host=213.171.218.249;port=3306",
> "dbuser","dbpass",
> {
> RaiseError => 1
> }
> );
>
> >
> > $SQL = "SELECT * FROM numbers";
> >
> > $sth = $dbh->prepare($SQL);
> > $sth->execute();
> };
> if($@){
> print $@;
> }
> > while (@row = $sth->fetchrow_array) { print @row; print "\n"; }
> > print "</body></html>";
Ah, now I'm getting somewhere! Using the eval expression I now get the
following:
"res: install_driver(mysql) failed: Can't load
'/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/auto/DBD/mysql/mysql.so'
for module DBD::mysql: libmysqlclient.so.10: cannot open shared object
file: No such file or directory at
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/DynaLoader.pm line 229. at
(eval 1) line 3 Compilation failed in require at (eval 1) line 3.
Perhaps a required shared library or dll isn't installed where expected
at numbers2.pl line 15 ed"
Which suggests to me that the web user on the server isn't getting the
same library paths back as I am when I SSH into the box? This is
something I can investigate now I have the error anyway!
Thanks for your help,
Ian.
------------------------------
Date: Wed, 22 Nov 2006 05:42:12 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Nov 22 2006
Message-Id: <J94AIC.1qC5@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-Viterbi-0.01
http://search.cpan.org/~koen/Algorithm-Viterbi-0.01/
Compute Viterbi path and probability
----
CGI-ContactForm-1.40
http://search.cpan.org/~gunnar/CGI-ContactForm-1.40/
Generate a web contact form
----
Catalyst-Plugin-Hooks-0.01
http://search.cpan.org/~berikv/Catalyst-Plugin-Hooks-0.01/
Add hooks to Catalyst engine actions
----
Catalyst-Plugin-Hooks-0.02
http://search.cpan.org/~berikv/Catalyst-Plugin-Hooks-0.02/
Add hooks to Catalyst engine actions
----
Email-Address-1.882
http://search.cpan.org/~rjbs/Email-Address-1.882/
RFC 2822 Address Parsing and Creation
----
FabForce-DBDesigner4-0.06
http://search.cpan.org/~reneeb/FabForce-DBDesigner4-0.06/
Parse/Analyse XML-Files created by DBDesigner 4 (FabForce)
----
Finance-TickerSymbols-0.03
http://search.cpan.org/~jezra/Finance-TickerSymbols-0.03/
Perl extension for getting symbols lists from web resources
----
IPC-DirQueue-0.08
http://search.cpan.org/~jmason/IPC-DirQueue-0.08/
disk-based many-to-many task queue
----
Inline-C2XS-0.08
http://search.cpan.org/~sisyphus/Inline-C2XS-0.08/
This module is deprecated. Install InlineX::C2XS instead.
----
InlineX-C2XS-0.09
http://search.cpan.org/~sisyphus/InlineX-C2XS-0.09/
create an XS file from Inline C code.
----
Jemplate-0.19
http://search.cpan.org/~ingy/Jemplate-0.19/
JavaScript Templating with Template Toolkit
----
Lingua-PT-PLN-0.12
http://search.cpan.org/~ambs/Lingua-PT-PLN-0.12/
Perl extension for NLP of the Portuguese Language
----
Lingua-PT-PLNbase-0.17
http://search.cpan.org/~ambs/Lingua-PT-PLNbase-0.17/
Perl extension for NLP of the Portuguese
----
MPEG-ID3v2Tag-0.38
http://search.cpan.org/~cbtilden/MPEG-ID3v2Tag-0.38/
Parses and creates ID3v2 Tags for MPEG audio files.
----
Module-ScanDeps-0.70
http://search.cpan.org/~smueller/Module-ScanDeps-0.70/
Recursively scan Perl code for dependencies
----
Nagios-Object-0.17
http://search.cpan.org/~tobeya/Nagios-Object-0.17/
----
Net-Packet-Target-1.01
http://search.cpan.org/~gomor/Net-Packet-Target-1.01/
an object for all network related stuff
----
PAR-0.960
http://search.cpan.org/~smueller/PAR-0.960/
Perl Archive Toolkit
----
POE-Component-CPAN-YACSmoke-0.03
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-0.03/
bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-YACSmoke-0.04
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-0.04/
bringing the power of POE to CPAN smoke testing.
----
POE-Filter-Zlib-1.8
http://search.cpan.org/~bingos/POE-Filter-Zlib-1.8/
A POE filter wrapped around Compress::Zlib
----
RT-Action-LinearEscalate-0.05
http://search.cpan.org/~jesse/RT-Action-LinearEscalate-0.05/
----
Sledge-Config-YAML-0.03
http://search.cpan.org/~mikihoshi/Sledge-Config-YAML-0.03/
The configuration file of Sledge can be written by using YAML.
----
Spreadsheet-SimpleExcel-1.5
http://search.cpan.org/~reneeb/Spreadsheet-SimpleExcel-1.5/
Create Excel files with Perl
----
Sys-Syscall-0.22
http://search.cpan.org/~bradfitz/Sys-Syscall-0.22/
access system calls that Perl doesn't normally provide access to
----
TM-1.21
http://search.cpan.org/~drrho/TM-1.21/
Topic Maps, Base Class
----
Test-CheckManifest-0.6
http://search.cpan.org/~reneeb/Test-CheckManifest-0.6/
Check if your Manifest matches your distro
----
Tie-Tk-Text-0.90
http://search.cpan.org/~mjcarman/Tie-Tk-Text-0.90/
Access Tk::Text or Tk::ROText widgets as arrays.
----
Tk-DiffText-0.14
http://search.cpan.org/~mjcarman/Tk-DiffText-0.14/
Perl/Tk composite widget for colorized diffs.
----
URI-ParseSearchString-0.9
http://search.cpan.org/~sden/URI-ParseSearchString-0.9/
parse Apache refferer logs and extract search engine query strings.
----
WebService-Geograph-API-0.04
http://search.cpan.org/~sden/WebService-Geograph-API-0.04/
Perl interface to the Geograph.co.uk API
----
bioperl-1.5.2_004-RCc
http://search.cpan.org/~sendu/bioperl-1.5.2_004-RCc/
----
bioperl-1.5.2_004-RCd
http://search.cpan.org/~sendu/bioperl-1.5.2_004-RCd/
----
bioperl-1.5.2_004-RCe
http://search.cpan.org/~sendu/bioperl-1.5.2_004-RCe/
----
dmake-4.7-20061120-SHAY
http://search.cpan.org/~shay/dmake-4.7-20061120-SHAY/
----
httpi-1.5.1
http://search.cpan.org/~ckaiser/httpi-1.5.1/
----
threads-1.52
http://search.cpan.org/~jdhedden/threads-1.52/
Perl interpreter-based threads
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: 22 Nov 2006 04:28:46 -0800
From: "mattsteel" <matteo_vitturi@virgilio.it>
Subject: Re: Perl is worth nothing!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Message-Id: <1164198526.067061.316070@m73g2000cwd.googlegroups.com>
robertospara ha scritto:
> It's to slow.
not in slurp mode.
------------------------------
Date: Wed, 22 Nov 2006 11:54:46 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl substitution working on some machines but not others?
Message-Id: <ek1dt9.k0.1@news.isolution.nl>
therocket79@yahoo.co.uk schreef:
> $new_file =~ s/^$from_dir/$to_dir/;
$new_file =~ s/^\Q$from_dir/$to_dir/;
See perldoc -f quotemeta.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 22 Nov 2006 07:09:28 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: use print to write binary data to a filehandle seems not correct
Message-Id: <Xns9883BC71A35Fcastleamber@130.133.1.4>
quakewang@mail.whut.edu.cn wrote:
> hi,
>
> I get a image data from the internet and then save it into a
> newcreated file, but seems the saved data is not the same as the
> original one.
>
> $file_name++;
> my $success = open FILE_HD, "> $file_name";
> if ( ! $success) {
> # The open failed
> warn $file_name . "open failed! [$!]\n";
> }
> print FILE_HD $response->content;
uhm, the open failed, what do you expect here to happen?
> close FILE_HD;
close ... or die ...
(yes, close can fail, especially after writing)
> why?
Even easier (instead of writing yourself using binmode [1]), read the
LWP::UserAgent documentation:
$ua->get( $url , $field_name => $value, ... )
...
Fields names that start with ``:'' are special. These will not
initialize headers of the request but will determine how the response
content is treated. The following special field names are recognized:
:content_file => $filename
so:
$ua->get( $url, ':content_file' => $filename );
...
...
[1] Also, check out File::Slurp
--
John Experienced Perl programmer: http://castleamber.com/
Perl help, tutorials, and examples: http://johnbokma.com/perl/
------------------------------
Date: 22 Nov 2006 03:50:05 -0800
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: use print to write binary data to a filehandle seems not correct
Message-Id: <1164196205.365087.198380@b28g2000cwb.googlegroups.com>
quakewang@mail.whut.edu.cn wrote:
> You said: "You haven't given enough information to lead to any
> reasonably certain solution."
>
> can you point out me a little furthur, what shall I give for this
> question,
Please read the Posting Guidelines that are posted to this group twice
a week. They will teach you how to construct a useful post.
Specifically, they instruct you to post a short-but-complete script
that we can run. In your post, we had no way of knowing what was
contained in your variables, other than your description. So we
couldn't possibly know if your description was accurate, or if you had
a bug in understanding the $response object, or any of a hundred other
things that could have been wrong.
Paul Lalli
------------------------------
Date: 22 Nov 2006 04:57:18 -0800
From: quakewang@mail.whut.edu.cn
Subject: Re: use print to write binary data to a filehandle seems not correct
Message-Id: <1164200238.700332.252190@j44g2000cwa.googlegroups.com>
"Paul Lalli =D0=B4=B5=C0=A3=BA
> Please read the Posting Guidelines that are posted to this group twice
> a week. They will teach you how to construct a useful post.
> Specifically, they instruct you to post a short-but-complete script
> that we can run. In your post, we had no way of knowing what was
> contained in your variables, other than your description. So we
> couldn't possibly know if your description was accurate, or if you had
> a bug in understanding the $response object, or any of a hundred other
> things that could have been wrong.
>
> Paul Lalli
I will post the complete script next time, it is a program to get
beautiful girl image from pic web site, now I can get pics, and save
them into files, but it is slow, and I found it is very difficult to
pick the wanted pic from handred of pics on every pages.
I will use fork to increase the scipt to max speed, and try to find a
way to pic the right pic I save as ... by hand ago.
yes, seems, sometime the binary write even fail, i get a image can not
be see by ACDSee, but that cases is rare, when I can download handreds
or thousands of pics a day, I will go to research that problem.
thanks.
------------------------------
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 9996
***************************************