[31303] in Perl-Users-Digest
Perl-Users Digest, Issue: 2548 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 13 16:09:41 2009
Date: Thu, 13 Aug 2009 13:09: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 Thu, 13 Aug 2009 Volume: 11 Number: 2548
Today's topics:
end-of-line conventions <no.email@please.post>
Re: FAQ 8.18 How can I do an atexit() or setjmp()/longj <nospam-abuse@ilyaz.org>
Re: FAQ 8.18 How can I do an atexit() or setjmp()/longj <willem@stack.nl>
Re: Getting file names with MIME::Parser <glex_no-spam@qwest-spam-no.invalid>
Re: more than one statement in a post perlish condition <justin.0908@purestblue.com>
Re: more than one statement in a post perlish condition <uri@stemsystems.com>
Re: more than one statement in a post perlish condition <willem@stack.nl>
Re: more than one statement in a post perlish condition <sbryce@scottbryce.com>
Re: more than one statement in a post perlish condition <uri@stemsystems.com>
Re: more than one statement in a post perlish condition <nat.k@gm.ml>
Re: more than one statement in a post perlish condition <peter@makholm.net>
Re: Newbie: perl program in a ksh here-document <jose.luis.fdez.diaz@gmail.com>
overridden method in perltoot <cmic@live.fr>
Re: overridden method in perltoot <zen13097@zen.co.uk>
Re: overridden method in perltoot <tadmc@seesig.invalid>
paring html file by using RegExp <dontmewithme@got.it>
Re: paring html file by using RegExp <tadmc@seesig.invalid>
Re: Question - anonymous recursive functions <peter@makholm.net>
STC Wx & Padre (isecc)
Re: STC Wx & Padre <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 13 Aug 2009 19:26:34 +0000 (UTC)
From: kj <no.email@please.post>
Subject: end-of-line conventions
Message-Id: <h61pd9$1at$1@reader1.panix.com>
There are three major conventions for the end-of-line marker:
"\n", "\r\n", and "\r".
In a variety of situation, Perl must split strings into "lines",
and must therefore follow a particular convention to identify line
boundaries. There are three situations that interest me in
particular: 1. the splitting into lines that happens when one
iterates over a file using the <> operator; 2. the meaning of the
operation performed by chomp; and 3. the meaning of the $ anchor
in regular expressions.
These three issues are tested by the following simple script:
my $lines = my $matches = 0;
while (<>) {
$lines++;
if (/z$/) {
$matches++;
chomp;
print ">$_<";
}
}
print "$/$matches matches out of $lines lines$/";
__END__
I have three files, unix.txt, dos.txt, and mac.txt, each containing
four lines. Disregarding the end-of-line character(s) these lines
are "foo", "bar", "baz", "frobozz".
The file unix.txt uses "\n" to separate the lines. The output that
I get when I pass it as the argument to the script is this:
% demo.pl unix.txt
>baz<>frobozz<
2 matches out of 4 lines
The file dos.txt uses "\r\n" to separate lines, and the file mac.txt
uses "\r". Here's the output I get when I pass these files to the
script:
% demo.pl dos.txt
0 matches out of 4 lines
% demo.pl mac.txt
0 matches out of 1 lines
How can I change the script so that the output for unix.txt, dos.txt,
and mac.txt will be the same as the one shown above for unix.txt?
(Mucking with the value of $/ I was able to get <> to split the
input stream at the right places, but it had no impact on the result
of the regular expression match.)
TIA!
kynn
------------------------------
Date: Thu, 13 Aug 2009 16:02:16 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: FAQ 8.18 How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
Message-Id: <slrnh88dof.8un.nospam-abuse@chorin.math.berkeley.edu>
On 2009-08-12, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
> I thought about this for a while and I think that the main difference
> for me is that I view an exception as a state, but exit as an action.
Exception is an action too: your throw it.
> Therefore exit isn't an exception, although it might be used to handle
> an exception.
>
> Other, more technical, differences are:
>
> An exception causes the stack to unwind until it hits an exception
> handler.
Not on OS/2. "A native" exception switches to a different stack, and
calls a handler with the processor state at time of exception as
arguments. The return value of the handler determines what to do
next. E.g., POSIX signals may be implemented via these exceptions.
Programming language exceptions MAY BE impemented via this mechanism,
although I strongly believe that CRTL implements them by direct stack
manipulation.
> exit doesn't (In C this makes a big difference, in Perl it
> might be academic: objects are still garbage-collected).
>
> You can't recover from calling exit.
AHA, I think I know how to fix it: AFAIK, on OS/2, calling exit() (the
native, non-POSIX way is DosExit()) just throws an exception. ;-)
> I was writing a possible use for setjmp/longjmp in C (exception
> handling) and how you would translate that into perl (die/eval).
Well, apparently it was hard to deduce from context... ;-)
Thanks,
Ilya
------------------------------
Date: Thu, 13 Aug 2009 16:10:48 +0000 (UTC)
From: Willem <willem@stack.nl>
Subject: Re: FAQ 8.18 How can I do an atexit() or setjmp()/longjmp()? (Exception handling)
Message-Id: <slrnh88eo8.291i.willem@turtle.stack.nl>
Ilya Zakharevich wrote:
) On 2009-08-12, Peter J. Holzer <hjp-usenet2@hjp.at> wrote:
)> I thought about this for a while and I think that the main difference
)> for me is that I view an exception as a state, but exit as an action.
)
) Exception is an action too: your throw it.
No, *throwing* an exception is an action.
The exception itself is not.
By analogy:
A ball is an action too: you throw it.
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Thu, 13 Aug 2009 12:47:26 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Getting file names with MIME::Parser
Message-Id: <4a8451ae$0$89876$815e3792@news.qwest.net>
Ed Jay wrote:
> I'm successfully using Mime::Parser to parse a multipart file containing
> binary files and save the contents (files) to my desired folder on the
> server. But... I do not know, nor do the docs tell me, how do I get the
> names of the file contents?
>
I've never used it, however it looks like what you're after
is in MIME::Parser::Filer.
------------------------------
Date: Thu, 13 Aug 2009 12:33:03 -0000
From: Justin C <justin.0908@purestblue.com>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <49c8.4a8407ff.16401@zem>
On 2009-08-11, Alexander Jack <abu.4000@gmail.com> wrote:
> Dear community ,
> I wanted to know that how do I give more than one statement in a post
> perlish condition ,
>
> for ex:
> print "YES" if ( $yes eq "yes");
>
> I want to change the value of $yes if it is true that means it should
> execute after
> print statement.
print "yes" if (($yes eq "yes") && ($yes = 'no'));
Justin.
--
Justin C, by the sea.
------------------------------
Date: Thu, 13 Aug 2009 11:10:02 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <87zla3g379.fsf@quad.sysarch.com>
>>>>> "JC" == Justin C <justin.0908@purestblue.com> writes:
JC> On 2009-08-11, Alexander Jack <abu.4000@gmail.com> wrote:
>> Dear community ,
>> I wanted to know that how do I give more than one statement in a post
>> perlish condition ,
>>
>> for ex:
>> print "YES" if ( $yes eq "yes");
>>
>> I want to change the value of $yes if it is true that means it should
>> execute after
>> print statement.
JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
it is nice to be helpful but better to be correct. the latter is = which
is very wrong in two ways: it is an assignment and not a comparison and
it is also numeric (assuming you meant ==) and not a string
comparison. then the logic is also tortured. why would you check for
'yes' and ALSO 'no'. it can't be both. next the OP wanted multiple
statements with a single modifier, not multiple booleans in one
modifier. finally all the parens aren't needed and are noisy.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 13 Aug 2009 15:34:51 +0000 (UTC)
From: Willem <willem@stack.nl>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <slrnh88ckr.28fo.willem@turtle.stack.nl>
Uri Guttman wrote:
)>>>>> "JC" == Justin C <justin.0908@purestblue.com> writes:
)
) JC> On 2009-08-11, Alexander Jack <abu.4000@gmail.com> wrote:
) >> I want to change the value of $yes if it is true that means it should
) >> execute after
) >> print statement.
)
) JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
)
) it is nice to be helpful but better to be correct. the latter is = which
) is very wrong in two ways: it is an assignment and not a comparison and
) it is also numeric (assuming you meant ==) and not a string
) comparison. then the logic is also tortured. why would you check for
) 'yes' and ALSO 'no'. it can't be both. next the OP wanted multiple
) statements with a single modifier, not multiple booleans in one
) modifier. finally all the parens aren't needed and are noisy.
*whoosh*
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
------------------------------
Date: Thu, 13 Aug 2009 09:35:43 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <h61cdt$ml1$1@news.eternal-september.org>
Uri Guttman wrote:
>
> JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
>
> it is nice to be helpful but better to be correct. the latter is =
> which is very wrong in two ways: it is an assignment and not a
> comparison and it is also numeric (assuming you meant ==) and not a
> string comparison. then the logic is also tortured. why would you
> check for 'yes' and ALSO 'no'. it can't be both. next the OP wanted
> multiple statements with a single modifier, not multiple booleans in
> one modifier. finally all the parens aren't needed and are noisy.
Did I miss something? What the OP wants to do is evaluate $yes. If $yes
contains 'yes', then print it and change its value.
The line if code JC provided does that. If $yes evaluates to 'yes' then
$yes is set to 'no'. Since setting $yes to 'no' evaluates to TRUE, the
print statement is executed.
use strict;
use warnings;
my $yes = 'yes';
print 'yes' if (($yes eq 'yes') && ($yes = 'no'));
print "\nYes now equals $yes";
----------
yes
Yes now equals no
------------------------------
Date: Thu, 13 Aug 2009 11:59:02 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <87prazg0xl.fsf@quad.sysarch.com>
>>>>> "SB" == Scott Bryce <sbryce@scottbryce.com> writes:
SB> Uri Guttman wrote:
>>
JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
>>
>> it is nice to be helpful but better to be correct. the latter is =
>> which is very wrong in two ways: it is an assignment and not a
>> comparison and it is also numeric (assuming you meant ==) and not a
>> string comparison. then the logic is also tortured. why would you
>> check for 'yes' and ALSO 'no'. it can't be both. next the OP wanted
>> multiple statements with a single modifier, not multiple booleans in
>> one modifier. finally all the parens aren't needed and are noisy.
SB> Did I miss something? What the OP wants to do is evaluate $yes. If $yes
SB> contains 'yes', then print it and change its value.
SB> The line if code JC provided does that. If $yes evaluates to 'yes' then
SB> $yes is set to 'no'. Since setting $yes to 'no' evaluates to TRUE, the
SB> print statement is executed.
not what i read but i could be wrong. in any case (and regardless of the
correctness of the above code) it is horrible. using assignment INSIDE a
conditional of a modifier is nuts. it should never be done especially in
a compound boolean. it LOOKS like a bug and will always be read as one.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 13 Aug 2009 10:39:24 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <gdYgm.112216$9P.33778@newsfe08.iad>
Willem wrote:
> Uri Guttman wrote:
> )>>>>> "JC" == Justin C <justin.0908@purestblue.com> writes:
> )
> ) JC> On 2009-08-11, Alexander Jack <abu.4000@gmail.com> wrote:
> ) >> I want to change the value of $yes if it is true that means it
> should
> ) >> execute after
> ) >> print statement.
> )
> ) JC> print "yes" if (($yes eq "yes") && ($yes = 'no'));
> )
> ) it is nice to be helpful but better to be correct. the latter is =
> which ) is very wrong in two ways: it is an assignment and not a
> comparison and ) it is also numeric (assuming you meant ==) and not a
> string ) comparison. then the logic is also tortured. why would you
> check for ) 'yes' and ALSO 'no'. it can't be both. next the OP wanted
> multiple ) statements with a single modifier, not multiple booleans in
> one ) modifier. finally all the parens aren't needed and are noisy.
>
> *whoosh*
>
>
> SaSW, Willem
LOL!
------------------------------
Date: Thu, 13 Aug 2009 21:41:58 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: more than one statement in a post perlish condition
Message-Id: <87zla3mrg9.fsf@vps1.hacking.dk>
Justin C <justin.0908@purestblue.com> writes:
>> print "YES" if ( $yes eq "yes");
>>
>> I want to change the value of $yes if it is true that means it should
>> execute after
>> print statement.
>
> print "yes" if (($yes eq "yes") && ($yes = 'no'));
As Uri has explained this is very prone to mis-readings and is thus
unmaintainable. If we go by the example you solution works, but the
assignment happens *before* the print statement, which could be argued
to be wrong according to "the spec".
//Makholm
------------------------------
Date: Wed, 12 Aug 2009 23:42:09 -0700 (PDT)
From: Jose Luis <jose.luis.fdez.diaz@gmail.com>
Subject: Re: Newbie: perl program in a ksh here-document
Message-Id: <46688fc3-feb6-405c-8b35-bee115b18e50@r38g2000yqn.googlegroups.com>
On Aug 12, 2:54=A0pm, Jose Luis <jose.luis.fdez.d...@gmail.com> wrote:
> Hi,
>
> #/usr/bin/ksh
>
> cat kk|perl - <<-"EOF"
>
> use strict;
> use warnings;
>
> while(<STDIN>)
> {
> print "$_";
>
> }
>
> EOF
>
> The shell script program above doesn't print on screen the file "kk".
> Any help?
>
> Thanks in advance,
> Jose Luis
This can be solved with the -e perl's option.
Regards,
Jose Luis
------------------------------
Date: Thu, 13 Aug 2009 07:34:53 -0700 (PDT)
From: cmic <cmic@live.fr>
Subject: overridden method in perltoot
Message-Id: <b26f0099-ecbd-409b-ad06-91e3cbff310e@d4g2000yqa.googlegroups.com>
Hi
context : PerlOO Newbie.
I don't understand why this excerpt from perltoot doesn't work as
expected.
It should print "In Employe::peers", but prints "In Person::peers"
instead.
Moreover, the complete example in perltoot ("Overridden method"
paragraph) doesn't work either.
Or do I miss something ?
--------file Person.pm-------------
#!/usr/local/bin/perl
package Person;
use strict; use warnings;
sub new {
my $self = {};
$self->{NAME} = undef;
bless($self);
return $self;
}
sub name {}
sub peers { print "in Person::peers\n";}
1;
--------------file Employe.pm -----------
#!/usr/local/bin/perl
package Employe;
use Person;
use vars qw (@ISA);
use strict; use warnings;
@ISA="Person";
sub peers {
printf "In Employe::peers\n";
}
----------file a.pl -----------
#!/usr/local/bin/perl
use Employe;
use strict;
use warnings;
my $emp=Employe->new();
print $emp->peers(), "\n";
TYA
--
michel marcon aka cmic
Unix Sysadmin
------------------------------
Date: 13 Aug 2009 14:50:15 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: overridden method in perltoot
Message-Id: <4a842827$0$2478$db0fefd9@news.zen.co.uk>
On Thu, 13 Aug 2009 07:34:53 -0700 (PDT), cmic <cmic@live.fr> wrote:
> Hi
> context : PerlOO Newbie.
> I don't understand why this excerpt from perltoot doesn't work as
> expected.
> It should print "In Employe::peers", but prints "In Person::peers"
> instead.
> Moreover, the complete example in perltoot ("Overridden method"
> paragraph) doesn't work either.
> Or do I miss something ?
It appears that you missed the perltoot section
"Planning for the Future: Better Constructors" where the constructor
is revised.
> --------file Person.pm-------------
> #!/usr/local/bin/perl
> package Person;
> use strict; use warnings;
> sub new {
> my $self = {};
> $self->{NAME} = undef;
> bless($self);
This blesses $self into the current package (i.e. Person) so, even
when called via the Employee constructor, the result is always a
Person, not an Employee.
You need to bless $self into the correct class (which is usually the
first parameter passed to the constructor):
sub new {
my $class = shift;
# ...
return bless $self, $class;
}
Now, when called via: $x = Person->new()
$x will be a Person, but when called via: $x = Employee->new()
then $x will be an Employee.
------------------------------
Date: Thu, 13 Aug 2009 09:56:56 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: overridden method in perltoot
Message-Id: <slrnh889u2.j95.tadmc@tadmc30.sbcglobal.net>
cmic <cmic@live.fr> wrote:
> I don't understand why this excerpt from perltoot doesn't work as
> expected.
> It should print "In Employe::peers", but prints "In Person::peers"
> instead.
> --------file Person.pm-------------
> #!/usr/local/bin/perl
> package Person;
> use strict; use warnings;
> sub new {
my $class = shift;
> my $self = {};
> $self->{NAME} = undef;
> bless($self);
bless($self, $class);
> return $self;
> }
See the "Planning for the Future: Better Constructors" section in perltoot,
and note what the single-arg form of bless() does:
perldoc -f bless
... Always use the two-argument version if a derived class might
inherit the function doing the blessing...
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 13 Aug 2009 14:37:11 +0200
From: "Larry" <dontmewithme@got.it>
Subject: paring html file by using RegExp
Message-Id: <4a8408f6$0$34622$4fafbaef@reader4.news.tin.it>
Hello,
I have a html file made up of data included in several rows & cells
of a html table: http://theartofweb.net/tabella.html
I'd like to grab some data from that table like the: "Titolo", "Prezzo",
"Var%" and "Ora" fields and include those data into an xml file, that's to
say I'd like to turn that html table into a xml file.
I guess the only way to accomplish that is to use perl's RegExp.
internally the html table looks like this:
<html>
<table id=tabella border=0 cellpadding=1 cellspacing=1 width=15%
bgcolor="#fffff0">
<tr ALIGN="center">
<th ALIGN="left"
width=15%>Titolo</th><th>Prezzo</th><th>Var%</th><th>Ora</th><th>Denaro</th><th>Qtà</th><th>Lettera</th><th>Qtà</th><th>N.Contr</th>
</tr>
<tr ALIGN="right" bgcolor=#E5E5E5><td ALIGN="left" nowrap><a
href=?modo=grafico&type=indice&tlv=ITLMS&service=rtlite&lang=it&t=&sid=7a78eef1rg4n5cpoqonmak5dm6>FTSE
Italia All-Share</a></td><td><b>22.337,8300</b></td><td nowrap><font
color="#00AA00"> +1,58%</font></td><td
ALIGN="center">13:51:00</td><td>0,0000</td><td>0.0</td><td>0,0000</td><td>0.0</td><td>0.0</td></tr><tr
ALIGN="right" bgcolor=#ffffff><td ALIGN="left" nowrap><a
href=?modo=scheda&tlv=IT0009417178&service=rtlite&lang=it&t=&sid=7a78eef1rg4n5cpoqonmak5dm6>FIBSP</a></td><td><b>21.910,0000</b></td><td
nowrap><font color="#00AA00"> +1,67%</font></td><td
ALIGN="center">13:51:05</td><td>21.910,0000</td><td>6</td><td>21.920,0000</td><td>6</td><td>0.0</td></tr><tr
ALIGN="right" bgcolor=#E5E5E5><td ALIGN="left" nowrap><a
href=?modo=scheda&tlv=IT0009672657&service=rtlite&lang=it&t=&sid=7a78eef1rg4n5cpoqonmak5dm6>MFIBSP</a></td><td><b>21.915,0000</b></td><td
nowrap><font color="#00AA00"> +1,69%</font></td><td
ALIGN="center">13:51:01</td><td>21.910,0000</td><td>7</td><td>21.920,0000</td><td>17</td><td>0.0</td></tr>
</table>
</html>
so the table starts off with a <tr> rows that includes all the
captions...then we've got all the other rows including the data...they all
are placed in one line so I shoud search for <tr ALIGN="right"
bgcolor=#E5E5E5>...</tr> to actually grab the data...take the following for
instance:
<tr ALIGN="right" bgcolor=#E5E5E5><td ALIGN="left" nowrap><a
href=?modo=grafico&type=indice&tlv=ITLMS&service=rtlite&lang=it&t=&sid=7a78eef1rg4n5cpoqonmak5dm6>FTSE
Italia All-Share</a></td><td><b>22.337,8300</b></td><td nowrap><font
color="#00AA00"> +1,58%</font></td><td
ALIGN="center">13:51:00</td><td>0,0000</td><td>0.0</td><td>0,0000</td><td>0.0</td><td>0.0</td></tr>
that is a regular row containing the data I wanna grab! from that line I'd
be just happy by grabbing the first for values such as:
FTSE Italia All-Share * 22.337,8300 * +1,58% * 13:51:00 (i think by
$1,$2,$3,$4) and putting them into an xml file
can it actually be done with perl regexp??
thanks!
------------------------------
Date: Thu, 13 Aug 2009 09:45:03 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: paring html file by using RegExp
Message-Id: <slrnh8897p.j95.tadmc@tadmc30.sbcglobal.net>
Larry <dontmewithme@got.it> wrote:
> I have a html file made up of data included in several rows & cells
> of a html table: http://theartofweb.net/tabella.html
>
> I'd like to grab some data from that table like the: "Titolo", "Prezzo",
> "Var%" and "Ora" fields and include those data into an xml file, that's to
> say I'd like to turn that html table into a xml file.
You should use a module that understands HTML for processing HTML data.
> I guess the only way to accomplish that is to use perl's RegExp.
The LAST CHOICE way to accomplish that is to use perl's RegExp!
Regular expressions are not up to the task of parsing a context
free language (such as HTML).
> internally the html table looks like this:
If you use a module that understands HTML, then you won't even
need to look at the "internals".
Since the data you want is in a table, HTML::TableExtract would
seem a good choice.
All you need to know is the headings for the rows that you want to get.
-----------------------
#!/usr/bin/perl
use warnings;
use strict;
use LWP::Simple;
use HTML::TableExtract;
use Data::Dumper;
my $html = get 'http://theartofweb.net/tabella.html';
my @headers = qw/Titolo Prezzo Var% Ora/;
my $te = HTML::TableExtract->new( headers => \@headers );
$te->parse($html);
foreach my $ts ( $te->tables ) {
foreach my $row ( $ts->rows ) {
my %f;
@f{@headers} = @$row;
print Dumper \%f;
}
}
-----------------------
Formatting the output as XML is left as an exercise for the reader.
> can it actually be done with perl regexp??
Who cares!
What really matters is can it actually be done with Perl.
Friends don't let friends parse HTML with regexes!
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 13 Aug 2009 13:42:39 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: Question - anonymous recursive functions
Message-Id: <87d470ndn4.fsf@vps1.hacking.dk>
Peter Makholm <peter@makholm.net> writes:
>> I want a function to be private inside a module, so - I made it
>> anonymous. Also I want it to be recursive - how to do that?
>
> You can also use namespace::clean for private functions:
I don't really like this interface, so I wrapped it up as an attribute
for subroutines. Soon to be available on CPAN as Sub::Private[0] or at
Github[1].
The you could just write:
package Foo;
use Sub::Private;
sub foo :Private {
return 42;
}
sub bar {
return foo() + 1;
}
1;
0) Allready uploaded, just waiting for the indexer
1) http://github.com/pmakholm/sub-private-perl/tree/master
//Makholm
------------------------------
Date: Thu, 13 Aug 2009 19:52:13 +0200
From: pbnew@tin.it (isecc)
Subject: STC Wx & Padre
Message-Id: <1j4ejsz.xpqjl1n1m37mN%pbnew@tin.it>
Hi all,
in order to try the Padre IDE I started an upgrade of serveral packages
on my system (OSX).
I've some problems building Wx.
perl Makefile.PL ends with:
ERROR from evaluation of .cpan/build/Wx-0.91-xh3jQ3/ext/Makefile.PL:
ERROR from evaluation of .cpan/build/Wx-0.91-xh3jQ3/ext/stc/Makefile.PL:
No such 'link' library: 'stc' at
.cpan/build/Wx-0.91-xh3jQ3/build/Wx/build/MakeMaker.pm line 211
MakeMaker at that line has:
sub get_core_lib {
my( $this, @libs ) = @_;
print "Getting lib: ", join "\n",@libs;
return join ' ', Alien::wxWidgets->libraries( @libs );
}
and infact it hangs when it's called with (stc,core).
Now... I haven't understood yet what stc package, binary, module, ...
should I install to solve the problem.
For example:
fink list stc
Information about 9210 packages read in 2 seconds.
distcc 2.18.3-1031 Distributed compilation tool
distcc-default 2.18.3-1031 Enable distcc+ccache by default
distcc-gtk 2.18.3-1028 GUI monitor for distcc build hosts
lighttpd-fastcgi 1.4.20-3 mod_fastcgi for lighttpd
gives no clues about that.
I have also the following packages installed:
fink list wxmac
Information about 9210 packages read in 2 seconds.
wxmac 2.6.3-1003rc1 Cross-platform GUI API - mac/carbon version
wxmac-shlibs 2.6.3-1003rc1 Cross-platform GUI API - mac/carbon version
i wxmac28 2.8.9-2 Cross-platform GUI API - mac/carbon version
i wxmac28-shlibs 2.8.9-2 Cross-platform GUI API - mac/carbon version
zphoto-wxmac 1.2-1023 Zooming photo album generator
Thanks in advance for any suggestion.
Regards.
------------------------------
Date: Thu, 13 Aug 2009 19:39:38 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: STC Wx & Padre
Message-Id: <a83el6-v1b.ln1@osiris.mauzo.dyndns.org>
Quoth pbnew@tin.it (isecc):
>
> in order to try the Padre IDE I started an upgrade of serveral packages
> on my system (OSX).
>
> I've some problems building Wx.
> perl Makefile.PL ends with:
>
> ERROR from evaluation of .cpan/build/Wx-0.91-xh3jQ3/ext/Makefile.PL:
> ERROR from evaluation of .cpan/build/Wx-0.91-xh3jQ3/ext/stc/Makefile.PL:
> No such 'link' library: 'stc' at
> .cpan/build/Wx-0.91-xh3jQ3/build/Wx/build/MakeMaker.pm line 211
I should take this to wxperl-users@perl.org, or, if you use IRC, to
#wxperl on irc.perl.org. AFAICT 'stc' is the Scintilla text editor
control, and is only available with the development (2.9) version of
wxWidgets, but I don't have any idea why Wx is trying to build against
it on your system.
Ben
------------------------------
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 2548
***************************************