[28286] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9650 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Aug 26 21:06:03 2006

Date: Sat, 26 Aug 2006 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 26 Aug 2006     Volume: 10 Number: 9650

Today's topics:
        graphics, gamedev, visualization community for Perl <ksamp@vp_removeit_.pl>
    Re: Match regular expression from LEFT to right <xicheng@gmail.com>
    Re: Match regular expression from LEFT to right <xicheng@gmail.com>
    Re: Perl's GUI <benmorrow@tiscali.co.uk>
    Re: Perl's GUI <dean.arnold@sbcglobal.net>
    Re: regular expression variables under debugger <rvtol+news@isolution.nl>
    Re: regular expression variables under debugger <news@lawshouse.org>
    Re: WinNT ActiveState STDERR and STDOUT <benmorrow@tiscali.co.uk>
    Re: xslt ? <mgarrish@gmail.com>
    Re: xslt ? <surfunbear@yahoo.com>
    Re: xslt ? <mgarrish@gmail.com>
    Re: xslt ? <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 26 Aug 2006 21:32:59 +0100
From: ks <ksamp@vp_removeit_.pl>
Subject: graphics, gamedev, visualization community for Perl
Message-Id: <5vb1f2lnoe87cqfql1bl17qc8lnfjntriv@4ax.com>

Hi all,
why don't we have such a place, page (to serve as a gathering point)
as Python has (http://pygame.org/wiki/about)?

best regards,
ks


------------------------------

Date: 26 Aug 2006 16:30:11 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Match regular expression from LEFT to right
Message-Id: <1156635011.530062.32100@i42g2000cwa.googlegroups.com>

fritz-bayer@web.de wrote:
> anno4000@radom.zrz.tu-berlin.de wrote:
> > fritz-bayer@web.de <fritz-bayer@web.de> wrote in comp.lang.perl.misc:
> > >
> > > anno4000@radom.zrz.tu-berlin.de wrote:
> > > > fritz-bayer@web.de <fritz-bayer@web.de> wrote in comp.lang.perl.misc:
> > > > > Hi,
> > > > >
> > > > > lets say I have the following string:
> > > > >
> > > > > <tr> dfsdfre <tr>fsdsfd35gd <tr>khf758 <tr>afdga654jhuotj <input
> > > > > type="text"> 67kfbs356</tr>sh tu65 </tr> hbrubs</tr>
> > > > >
> > > > > and I would like to capture the text before the <input...> until the
> > > > > first <tr> and the text after until the first <tr> so that I get
> > > > >
> > > > > <tr>afdga654jhuotj <input type="text> 67kfbs356</tr>
> > > > >
> > > > > How would I do this?
> > > > >
> > > > > =~ m!<tr>.*?<input type="text">.*?<tr>!
> > > > >
> > > > > will only work capturing the first <tr> after the <input..>. The
> > > > > problem is that I have to find a expression, which starts looking from
> > > > > the right to the left of <input...>.
> > > >
> > > > Your explanation is confused about whether the closing part should
> > > > be <tr> or </tr>.  Please clear that up.
> > > >
> > > > Anno
> > >
> > > Hi Anno,
> > >
> > > this is just an example. Actually I'm not looking for a concrete
> > > solution for this. It's just an example to illustrate my problem.
> >
> > Right.  Because it is meant to illustrate the problem it is important
> > that you make it consistent.
>
> Hi Anno, sorry you are right. The thing is my real example contains so
> much text that I did not want to post it here. But of course, if I
> don't I'm likely to get the right answer on the wrong question.
>
> So let me explain this words - as I did below. I'm trying to capture a
> group of radio buttons which resides inside a table in the middle of a
> html document, which contains lots of tags and text.
>
> Capturing the back of the html table after the radio buttons is easy as
> a ".*?</table>, will do the job. However, capturing the first <table>
> tag before the radio button group is more difficult, because there are
> plenty of table tags before.
>
> Actually I only want to get the rows in the table, which contain the
> radio buttons, but I guess once I get the table I can just strip the
> table tags off.
>

Dont know if this helps:

1) if there is not any other <input type="text"> tags, then it's easy:

  m#(<tr>(?:(?!<tr>).)*?<input\s+type="text">.*?</tr>)#sgi

(?:(?!<tr>).) construct will make sure there is not another <tr>
between the opening <tr> and your <input> tag.

add s modifier to allow dot match newline..

2) If there are more than 2 <input type="text"> tags within the table,
then try add some more constraints. Here I add another anchor:

m{ <table>
# anything except "<input type="text">"
  (?:(?!<input type="text">).)*?
# start of capturing $1
  (
    <tr>
# anything but "<tr>"
    (?:(?!<tr>).)*?
    <input\s+type="text">.*?
    </tr>
# end of capturing $1
  )
}sxi

You can use a similar way to get another one..

Good luck
Xicheng



------------------------------

Date: 26 Aug 2006 17:25:12 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: Match regular expression from LEFT to right
Message-Id: <1156638312.258521.240570@b28g2000cwb.googlegroups.com>

Xicheng Jia wrote:
> fritz-bayer@web.de wrote:
> > anno4000@radom.zrz.tu-berlin.de wrote:
> > > fritz-bayer@web.de <fritz-bayer@web.de> wrote in comp.lang.perl.misc:
> > > >
> > > > anno4000@radom.zrz.tu-berlin.de wrote:
> > > > > fritz-bayer@web.de <fritz-bayer@web.de> wrote in comp.lang.perl.misc:
> > > > > > Hi,
> > > > > >
> > > > > > lets say I have the following string:
> > > > > >
> > > > > > <tr> dfsdfre <tr>fsdsfd35gd <tr>khf758 <tr>afdga654jhuotj <input
> > > > > > type="text"> 67kfbs356</tr>sh tu65 </tr> hbrubs</tr>
> > > > > >
> > > > > > and I would like to capture the text before the <input...> until the
> > > > > > first <tr> and the text after until the first <tr> so that I get
> > > > > >
> > > > > > <tr>afdga654jhuotj <input type="text> 67kfbs356</tr>
> > > > > >
> > > > > > How would I do this?
> > > > > >
> > > > > > =~ m!<tr>.*?<input type="text">.*?<tr>!
> > > > > >
> > > > > > will only work capturing the first <tr> after the <input..>. The
> > > > > > problem is that I have to find a expression, which starts looking from
> > > > > > the right to the left of <input...>.
> > > > >
> > > > > Your explanation is confused about whether the closing part should
> > > > > be <tr> or </tr>.  Please clear that up.
> > > > >
> > > > > Anno
> > > >
> > > > Hi Anno,
> > > >
> > > > this is just an example. Actually I'm not looking for a concrete
> > > > solution for this. It's just an example to illustrate my problem.
> > >
> > > Right.  Because it is meant to illustrate the problem it is important
> > > that you make it consistent.
> >
> > Hi Anno, sorry you are right. The thing is my real example contains so
> > much text that I did not want to post it here. But of course, if I
> > don't I'm likely to get the right answer on the wrong question.
> >
> > So let me explain this words - as I did below. I'm trying to capture a
> > group of radio buttons which resides inside a table in the middle of a
> > html document, which contains lots of tags and text.
> >
> > Capturing the back of the html table after the radio buttons is easy as
> > a ".*?</table>, will do the job. However, capturing the first <table>
> > tag before the radio button group is more difficult, because there are
> > plenty of table tags before.
> >
> > Actually I only want to get the rows in the table, which contain the
> > radio buttons, but I guess once I get the table I can just strip the
> > table tags off.
> >
>
> Dont know if this helps:
>
> 1) if there is not any other <input type="text"> tags, then it's easy:
>
>   m#(<tr>(?:(?!<tr>).)*?<input\s+type="text">.*?</tr>)#sgi
>
> (?:(?!<tr>).) construct will make sure there is not another <tr>
> between the opening <tr> and your <input> tag.
>
> add s modifier to allow dot match newline..
>
> 2) If there are more than 2 <input type="text"> tags within the table,
> then try add some more constraints. Here I add another anchor:

I should have said:

2) If there are some more <input type="text"> tags outside/inside the
table, then try to add more constraints. and It's not an anchor that I
added here but just some more contexts....Sorry for my English....:-(

Good luck
Xicheng



------------------------------

Date: Sat, 26 Aug 2006 17:37:03 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Perl's GUI
Message-Id: <fu96s3-aa8.ln1@osiris.mauzo.dyndns.org>


Quoth zentara <zentara@highstream.net>:
> 
> WxPerl is based on Perl/Gtk2.

No it isn't. wxPerl is a Perl binding for the wxWidgets toolkit, which
is a cross-platform GUI. It can be built to use Gtk; it can also use
Motif or raw X11 under unix, and native gui widgets under Max OS X and
Win32.

It's biggest disadvantage is that the Perl bindings are not very well
documented, and you end up having to translate from the C++ docs.

> Now for the bad news. Perl/Gtk2 can make it very difficult to do
> what is simple in Tk. The most obvious thing is colorization of
> widgets. Gtk2 has a powerful "theme" system, so you can make all your
> apps look like your other Gtk2 apps like mozilla. BUT, that same theme
> system, makes it quite difficult to give custom colors and fonts  to
> individual widgets.
> Tk dosn't have that problem.  

It's not a problem: that's the *whole* *point*. You shouldn't be messing
about making everything silly colours: it just makes things harder for
your users.

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality. [Samuel Butler, paraphrased] benmorrow@tiscali.co.uk


------------------------------

Date: Sat, 26 Aug 2006 18:35:41 GMT
From: Dean Arnold <dean.arnold@sbcglobal.net>
Subject: Re: Perl's GUI
Message-Id: <1w0Ig.3303$yO7.2612@newssvr14.news.prodigy.com>

Ben Morrow wrote:
> Quoth zentara <zentara@highstream.net>:
>> WxPerl is based on Perl/Gtk2.
> 
> No it isn't. wxPerl is a Perl binding for the wxWidgets toolkit, which
> is a cross-platform GUI. It can be built to use Gtk; it can also use
> Motif or raw X11 under unix, and native gui widgets under Max OS X and
> Win32.
> 
> It's biggest disadvantage is that the Perl bindings are not very well
> documented, and you end up having to translate from the C++ docs.
> 

s/very well//;

BTW: some of the bindings are in fact different than the C++ version.
And for extra fun, you get to guess which ones!

That said, you may have some success using wxGlade as a GUI builder,
as long as you're not doing anything too complicated.

However, IMNSHO, browser based is the way to go
for any modern GUI. Yes, there are some limitations, but you might
be surprised at what can be accomplished using (e.g.) Dojo
(http://www.dojotoolkit.org/), Rico (http://www.openrico.org/rico/home.page),
script.aculo.us (http://script.aculo.us/), etc. And if all you need is
some simple forms, then simple HTML may be sufficient.

Dean Arnold
Presicient Corp.


------------------------------

Date: Sat, 26 Aug 2006 19:58:15 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: regular expression variables under debugger
Message-Id: <ecq9ck.1bg.1@news.isolution.nl>

wlcna schreef:


> ---------------------
>

Missing:

#!/usr/bin/perl
  use warnings ;
  use strict ;

> # HTML version
> use LWP::Simple;
> use HTML::TreeBuilder;
>
> my $strUrl = 'http://rss.news.yahoo.com/rss/us';
>
> my $strHtml = get( $strUrl );
>
> my $t = new HTML::TreeBuilder;
> $t->parse( $strHtml );
> $t->eof;
>
> my $str = $t->content->[0]->content->[0]->as_text;
> $str =~ /(.*)news/i;
> my $testPart = $1;
> my $testWhole = $&;
>
> my $breakpoint = 3;
> print "testPart: <$testPart>, testWhole: <$testWhole>\n";
>
> ---------------------
>
> And I may as well show the related XML version which still produces
> the error.  This code pulls out the exact same string using the same
> final access method "as_text".  And this one does show the problem
> (again, for me of course).
>
> ---------------------
>
> #!/usr/bin/perl

Missing:

  use warnings ;



> use strict;
>
> # *SECOND* XML and RSS VERSION
> use LWP::Simple;
> use XML::TreeBuilder;
>
> my $strUrl = 'http://rss.news.yahoo.com/rss/us';
>
> # retrieve
> my $strHtml = get( $strUrl );
>
> # parse the data retrieved.
> my $t = new XML::TreeBuilder;
> $t->parse( $strHtml );
> $t->eof;
>
> my $str = $t->content->[1]->content->[1]->as_text;

> $str =~ /(.*)news/i;
> my $testPart = $1;
> my $testWhole = $&;
> my $breakpoint = 3;
> print "testPart: $testPart, testWhole: $testWhole\n";

  if ($str =~ /(.*)news/i)
  {
     my $testPart   = $1;
     my $testWhole  = $&;
     my $breakpoint = 3;
     print "testPart  <$testPart>\n" ;
     print "testWhole <$testWhole>\n" ;
  }
  else
  {
    die "no match" ;
  }

-- 
Affijn, Ruud

"Gewoon is een tijger."




------------------------------

Date: Sat, 26 Aug 2006 23:19:45 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: regular expression variables under debugger
Message-Id: <1156630781.11058.0@proxy00.news.clara.net>

wlcna wrote:

> It's there, see my other post to your neighbor in this thread.

NNTP doesn't maintain rigid sequence of posts so I have no clue which 
one you're talking about.  I did find a post containing some code of 
yours, which I copied and pasted into a file, to see if I could help 
you, but running it produces this:

> F:\WIP>wlcna.pl
> syntax error at F:\WIP\wlcna.pl line 26, near ", for
> "
> "use" not allowed in expression at F:\WIP\wlcna.pl line 31, at end of line
> BEGIN not safe after errors--compilation aborted at F:\WIP\wlcna.pl line 34.

Goodbye.

-- 

Henry Law       <><     Manchester, England


------------------------------

Date: Sat, 26 Aug 2006 17:29:43 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: WinNT ActiveState STDERR and STDOUT
Message-Id: <ng96s3-aa8.ln1@osiris.mauzo.dyndns.org>


Quoth "addinall" <addinall@addinall.org>:
> Thomas Kratz wrote:
> >
> > But you can specify a different log file as
> >
> > my @t = timeout_system( 5, 'c:\Perl\bin\HELLO.BAT >log2 2>&1') ;
> 
> Thanks for your response.  I really appreciate it.
> I tried fudging it to a different log file (before I read this
> actually) and it seems that under this particular OS (NT4)
> NO file redirection works under a process that has dup()ed
> a handle. log2 doesn't even get created...  Grrrr.....

AFAIK the POSIXish redirection operators don't work at all under NT4. I
would recommend you build something yourself out of Win32::Process; not
a terribly pleasant task :(...

Ben

-- 
           All persons, living or dead, are entirely coincidental.
benmorrow@tiscali.co.uk                                           Kurt Vonnegut


------------------------------

Date: 26 Aug 2006 13:58:01 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: xslt ?
Message-Id: <1156625881.427293.60370@74g2000cwt.googlegroups.com>


surf wrote:

> > surf <surfunbear@yahoo.com> wrote:
> > >
> > >> surf <surfunbear@yahoo.com> wrote:
> > >>
> > >>
> > >> > I'm not sure why anyone would want
> > >> > to write a program of any sort in XML anyway ?
> > >>
>
>  There has not been allot of response from perl users here, I'm not
> sure if perl programmers have much interest in xml ...
>

I don't know that there's any correlation to be made between the lack
of interest in your post and the use of xml by perl programmers. If
anything, it just shows that you asked an uninteresting and slighty
off-topic question that's getting the attention it merits.

If you have any real questions about xslt or xml and perl, go ahead and
ask. If you just want an explanation of the merits of xslt you're
asking in the wrong forum.

And as a word of advice, you might consider laying off the
over-simplifications in the future. Your remark about why anyone would
use xml shows your level of understanding is quite low, and that will
stop most people from reading anything else you have to say.

Matt



------------------------------

Date: 26 Aug 2006 14:17:50 -0700
From: "surf" <surfunbear@yahoo.com>
Subject: Re: xslt ?
Message-Id: <1156627070.257758.301930@i42g2000cwa.googlegroups.com>


Matt Garrish wrote:
> surf wrote:
>
> > > surf <surfunbear@yahoo.com> wrote:
> > > >
> > > >> surf <surfunbear@yahoo.com> wrote:
> > > >>
> > > >>
> > > >> > I'm not sure why anyone would want
> > > >> > to write a program of any sort in XML anyway ?
> > > >>
> >
> >  There has not been allot of response from perl users here, I'm not
> > sure if perl programmers have much interest in xml ...
> >
>
> I don't know that there's any correlation to be made between the lack
> of interest in your post and the use of xml by perl programmers. If
> anything, it just shows that you asked an uninteresting and slighty
> off-topic question that's getting the attention it merits.
>
> If you have any real questions about xslt or xml and perl, go ahead and
> ask. If you just want an explanation of the merits of xslt you're
> asking in the wrong forum.
>
> And as a word of advice, you might consider laying off the
> over-simplifications in the future. Your remark about why anyone would
> use xml shows your level of understanding is quite low, and that will
> stop most people from reading anything else you have to say.
>

  Tad seem to imply perl is less suited for XML due to being optimized
for humans,
I think that is more of an oversimplication of anything I have said.



------------------------------

Date: 26 Aug 2006 14:43:58 -0700
From: "Matt Garrish" <mgarrish@gmail.com>
Subject: Re: xslt ?
Message-Id: <1156628638.897887.196330@m79g2000cwm.googlegroups.com>


surf wrote:

> Matt Garrish wrote:
> > And as a word of advice, you might consider laying off the
> > over-simplifications in the future. Your remark about why anyone would
> > use xml shows your level of understanding is quite low, and that will
> > stop most people from reading anything else you have to say.
> >
>
>   Tad seem to imply perl is less suited for XML due to being optimized
> for humans,
> I think that is more of an oversimplication of anything I have said.

He never said anything of the sort:

<requote Tad's earlier post>
XSLT is optimized for machines rather than for humans.

Let's haul this back on-topic:

Contrast that with Perl, which is optimized for humans at the
expense of the machine (throwing cycles and memory at a problem).
</quote>

He made a valid statement about using XSLT for transforming XML as
opposed to using perl, which is that XSLT is better optimized than
anything you'll be able to do in pure perl. That doesn't mean that perl
is not good for XML, only that you'll get better speed from an XSLT
processor.

There is a price to be paid for using perl, but anyone who uses perl
for anything (not just XML) is aware of that price and can live with
it. If your needs go beyond the sometimes limited boundaries of XSLT,
then perl is a good choice, and I see nothing in Tad's earlier post to
refute that or to say that it's not. Every company I've worked for has
used perl for at least some of their xml needs, so it must be doing
something right.

Matt



------------------------------

Date: Sat, 26 Aug 2006 18:05:51 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: xslt ?
Message-Id: <slrnef1kuf.sce.tadmc@magna.augustmail.com>

surf <surfunbear@yahoo.com> wrote:
> 
> Matt Garrish wrote:
>> surf wrote:
>>
>> > > surf <surfunbear@yahoo.com> wrote:
>> > > >
>> > > >> surf <surfunbear@yahoo.com> wrote:
>> > > >>
>> > > >>
>> > > >> > I'm not sure why anyone would want
>> > > >> > to write a program of any sort in XML anyway ?
>> > > >>
>> >
>> >  There has not been allot of response from perl users here, I'm not
>> > sure if perl programmers have much interest in xml ...
>> >
>>
>> I don't know that there's any correlation to be made between the lack
>> of interest in your post and the use of xml by perl programmers. If
>> anything, it just shows that you asked an uninteresting and slighty
>> off-topic question that's getting the attention it merits.
>>
>> If you have any real questions about xslt or xml and perl, go ahead and
>> ask. If you just want an explanation of the merits of xslt you're
>> asking in the wrong forum.
>>
>> And as a word of advice, you might consider laying off the
>> over-simplifications in the future. Your remark about why anyone would
>> use xml shows your level of understanding is quite low, and that will
>> stop most people from reading anything else you have to say.
>>
> 
>   Tad seem to imply perl is less suited for XML due to being optimized
> for humans,


Huh?


If you are a human, then you are likely to prefer using Perl.

If you are a machine (or writing one), then you are likely to
prefer using XSLT.


I am a human.

I always use Perl for processing markup languages, I never use XSLT.

But that's just me.


> I think that is more of an oversimplication of anything I have said.


I cannot fathom how what I said (that was not quoted, BTW) could
imply _your_ incorrect oversimplication.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

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 9650
***************************************


home help back first fref pref prev next nref lref last post