[28949] in Perl-Users-Digest
Perl-Users Digest, Issue: 193 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 5 00:10:09 2007
Date: Sun, 4 Mar 2007 21:09:05 -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 Sun, 4 Mar 2007 Volume: 11 Number: 193
Today's topics:
Re: Calling a module style question <sigzero@gmail.com>
Re: Calling a module style question xhoster@gmail.com
Re: Calling a module style question <tadmc@augustmail.com>
Re: Choosing the path based on the system "uname" comma <rvtol+news@isolution.nl>
Re: convert wikipedia to html? anno4000@radom.zrz.tu-berlin.de
Re: DocumentHTML ? <rvtol+news@isolution.nl>
Re: Expressing AND, OR, and NOT in a Single Pattern xhoster@gmail.com
Re: Expressing AND, OR, and NOT in a Single Pattern <wahab-mail@gmx.de>
Re: Posting to nntp newsgroup with Perl (Net::NNTP) <sadie001@nopsam.plannet.nl>
Re: Posting to nntp newsgroup with Perl (Net::NNTP) (Jamie)
Re: Question about scoping <megapode@gmail.com>
Question about wizard Perl programmers <jgrace5@gmail.com>
Re: Question about wizard Perl programmers <uri@stemsystems.com>
Re: Question about wizard Perl programmers <g_m@remove-comcast.net>
Statistical software - source code available <vincent64@yahoo.com>
Tk::DropSite question <g_m@remove-comcast.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Mar 2007 11:33:24 -0800
From: "Robert Hicks" <sigzero@gmail.com>
Subject: Re: Calling a module style question
Message-Id: <1173036804.280952.87920@j27g2000cwj.googlegroups.com>
On Mar 4, 1:13 pm, Uri Guttman <u...@stemsystems.com> wrote:
> >>>>> "RH" == Robert Hicks <sigz...@gmail.com> writes:
>
> RH> I have a subroutine that will be called every now and then and only
> RH> manually. It uses a module that isn't used by anything else in my
> RH> application. Is it okay (i.e. good style) to put the "use" statement
> RH> in that subroutine so it only get loaded when that specific subroutine
> RH> is called?
>
> that will force it to be loaded at compile time so it will be loaded
> always. the require function will load a module at runtime which is what
> you want.
>
> perldoc -f use
> perldoc -f require
>
> uri
>
Thank you Uri..!
Robert
------------------------------
Date: 04 Mar 2007 19:50:46 GMT
From: xhoster@gmail.com
Subject: Re: Calling a module style question
Message-Id: <20070304145646.428$4w@newsreader.com>
"Robert Hicks" <sigzero@gmail.com> wrote:
> I have a subroutine that will be called every now and then and only
> manually.
It is not clear to me what that means. Does every now and then describe
what happens during the course of a long running program, or how often
a short running program is running? How does being run only manually
distinguish it from the rest of the code, or the rest of whatever it is
you are trying to distinguish it from?
> It uses a module that isn't used by anything else in my
> application. Is it okay (i.e. good style) to put the "use" statement
> in that subroutine so it only get loaded when that specific subroutine
> is called?
Yes and no. I think it is good practice to put the use statement in the
subroutine (as long as you are fairly sure the code won't change to such
that that module will also be used elsewhere), but doing so makes the
module load when the specific subroutine is compiled, not when it is
executed.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sun, 4 Mar 2007 14:30:46 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Calling a module style question
Message-Id: <slrneumb3m.mce.tadmc@tadmc30.august.net>
Robert Hicks <sigzero@gmail.com> wrote:
> I have a subroutine that will be called every now and then and only
> manually. It uses a module that isn't used by anything else in my
> application. Is it okay (i.e. good style) to put the "use" statement
> in that subroutine so it only get loaded when that specific subroutine
> is called?
What happened when you tried it?
That will NOT result in it only getting loaded when that specific
subroutine is called.
"use" happens at compile time while the call happens later (at runtime).
ie. when you get to a time when it is possible to call the subroutine,
the module will already have been loaded.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 5 Mar 2007 01:31:34 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Choosing the path based on the system "uname" command
Message-Id: <esfs0k.19s.1@news.isolution.nl>
doni schreef:
> I want to write a program that does check the appropriate system path
> for perl in FreeBSD and Linux.
which -a perl
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 4 Mar 2007 19:41:45 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: convert wikipedia to html?
Message-Id: <550lnpF230fpaU1@mid.dfncis.de>
dt <ppc@cheapbooks.com> wrote in comp.lang.perl.misc:
> I have looked at all the perl modules and code for getting wikipedia
> data to html and I have found nothing that does that or nothing that
> works.
>
> the WebService-SimpleAPI-Wikipedia-0.01 does not seem to be a working
> distro (perl Makefile.pl does not run)
>
> is there an easy way to convert a WIKI page to html by querying the
> site, keeping all the formatting?
Huh? It *is* html as it comes. Just save it.
Anno
------------------------------
Date: Mon, 5 Mar 2007 01:40:51 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: DocumentHTML ?
Message-Id: <esfsje.1io.1@news.isolution.nl>
~greg schreef:
> I am trying to get an InternetExplorer.Application to print out
> the whole HTML document as text,
> from the <HTML> (or before) to the </HTML>.
> (-so as to feed it to a TreeBuilder parse).
Try wget.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 04 Mar 2007 20:24:26 GMT
From: xhoster@gmail.com
Subject: Re: Expressing AND, OR, and NOT in a Single Pattern
Message-Id: <20070304153027.299$sR@newsreader.com>
"Brian McCauley" <nobull67@gmail.com> wrote:
> On Mar 1, 10:10 pm, xhos...@gmail.com wrote:
> > "usaims" <usa...@yahoo.com> wrote:
> > > I'm having a little problem with this example in the Perl Cookbook.
> >
> > > True if pattern BAD does not match, but pattern GOOD does:
> > > /(?=(?:(?!BAD).)*$)GOOD/s
> >
> > Every character from the start of the match to the end of the string
> > has to not (be the start of a) match to BAD. However, if BAD occurs
> > before GOOD, the regex can still match, simply by not initiating the
> > match until after the B of BAD.
> >
> > You want to the forced exclusion to start at the beginning of the
> > string and run to the end:
> >
> > /^(?=(?:(?!BAD).)*$).*GOOD/;
>
> That's exponentially (er, factorially?) ineficient!
Under what condistions is it exponential? With the patterns I've tested,
it seems to be linear, not exponential. (But still a quite a lot slower
than yours, for reasons I don't quite understand. It would make more sense
to me if it were exponentially slower, rather than constantly 30 times
slower.)
Xho
>
> /^(?!.*BAD).*GOOD/;
>
> > But I'd just use two different regex.
>
> Yes, of course, that's still the best way.
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sun, 04 Mar 2007 21:31:48 +0100
From: Mirco Wahab <wahab-mail@gmx.de>
Subject: Re: Expressing AND, OR, and NOT in a Single Pattern
Message-Id: <esfan0$810$1@mlucom4.urz.uni-halle.de>
Brian McCauley wrote:
> On Mar 1, 10:10 pm, xhos...@gmail.com wrote:
>> You want to the forced exclusion to start at the beginning of the string
>> and run to the end:
>>
>> /^(?=(?:(?!BAD).)*$).*GOOD/;
>
> That's exponentially (er, factorially?) ineficient!
>
> /^(?!.*BAD).*GOOD/;
>
>> But I'd just use two different regex.
>
> Yes, of course, that's still the best way.
This
/^(?!.*BAD).*GOOD/
is, in my opinion, of "Maxwellian beauty".
I tried some time to get the original
expression somehow simplified, it (I)
ended with 'throwing the gun'.
Thanks,
Mirco
------------------------------
Date: Sun, 4 Mar 2007 22:40:54 +0100
From: "sadie-no-reply" <sadie001@nopsam.plannet.nl>
Subject: Re: Posting to nntp newsgroup with Perl (Net::NNTP)
Message-Id: <45eb3cf1$0$13606$ba620dc5@text.nova.planet.nl>
Thanks for the tip. It returns:
340 <45eb1d1b$0$3748$ba620dc5@text.nova.planet.nl> (desired) Article has no
body -- just headers
After checking RFC977&850, I changed @message into:
@message=(
"Subject: dit is test 2
From: cllq\@noreply.nil
Newsgroups: nl.test
Date: Sat, 4 Mar 2007 20:45:13 +0100
Hier staat de eerste regel
Hier de tweede
.");
And it seems to work. At least returns ok status. Haven't seen the result
back, though...
"Peter J. Holzer" <hjp-usenet2@hjp.at> schreef in bericht
news:slrneulg03.hgd.hjp-usenet2@yoyo.hjp.at...
> On 2007-03-04 12:05, sadie-no-reply <sadie001@nopsam.plannet.nl> wrote:
>> I am trying to post a message to a newsgroup using Net::NNTP, but I keep
>> getting an error message. Help!
> [...]
>> #now post the message
>> $nntp->post(@message) or die "post failed"; #this one fails, but why?
>
> Why ask us? Ask perl:
>
> $nntp->post(@message) or die "post failed: " . $nntp->message();
>
> hp
>
>
> --
> _ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
> |_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
> | | | hjp@hjp.at | andere ersetzt.
> __/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: Mon, 05 Mar 2007 01:04:53 GMT
From: nospam@geniegate.com (Jamie)
Subject: Re: Posting to nntp newsgroup with Perl (Net::NNTP)
Message-Id: <Lc117303648738610x8d13364@pong.podro.com>
In <45eb3cf1$0$13606$ba620dc5@text.nova.planet.nl>,
"sadie-no-reply" <sadie001@nopsam.plannet.nl> mentions:
>Thanks for the tip. It returns:
>340 <45eb1d1b$0$3748$ba620dc5@text.nova.planet.nl> (desired) Article has no
>body -- just headers
>
>After checking RFC977&850, I changed @message into:
>
>@message=(
>"Subject: dit is test 2
>From: cllq\@noreply.nil
>Newsgroups: nl.test
>Date: Sat, 4 Mar 2007 20:45:13 +0100
>
>Hier staat de eerste regel
>Hier de tweede
>.");
>
>And it seems to work. At least returns ok status. Haven't seen the result
>back, though...
You might look into the datasend(), dataend() methods of Net::Cmd (these
are inherited by Net::NNTP, so you can use them withing a $nntp object
as well)
Not saying it's proper, but I generally just use telnet combined with
Net::Cmd and Net::NNTP. (actually, you could easily just use Net::Cmd if
you wanted) telnet for debugging and getting a feel for what the perl
modules are doing.
# The critical bits from one of my "inews" clone scripts:
#
# I left out the connect and alarm wrappers.
#
$nntp->post();
while(my $line = <>){
$nntp->datasend($line);
}
$nntp->dataend();
unless($nntp->ok()){
die sprintf("NNTP[%03d] %s\n",$nntp->code(),$nntp->message());
}
Try posting a small article (to a test group) with telnet to get a feel
for how NNTP works. It'll make using the perl modules easier.
Jamie
--
http://www.geniegate.com Custom web programming
Perl * Java * UNIX User Management Solutions
------------------------------
Date: 4 Mar 2007 20:06:53 -0800
From: "Bob Dubery" <megapode@gmail.com>
Subject: Re: Question about scoping
Message-Id: <1173067613.738325.18440@h3g2000cwc.googlegroups.com>
John's reply was informative, but it did not address my immediate
concern.
However, I think I may have moved on to a state where I remain
confused, but confused at a higher level :-)
Considering this....
eval {new XML::DOM::Parser->parse($headerFile)};
Is it the case that because neither the parser object nor the results
of the eval are assigned to any kind of variable that either or both
are regarded as barewords?
------------------------------
Date: 4 Mar 2007 20:12:11 -0800
From: "LovesHisLittleShad" <jgrace5@gmail.com>
Subject: Question about wizard Perl programmers
Message-Id: <1173067931.041020.191050@c51g2000cwc.googlegroups.com>
Is it my imagination, or is Perl a million times harder than other
languages? Looking at books on all the languages of the past (I'm a
programmer), I've notices that Perl is the only one that seems greek
in most chapters, with very little explanation of what the people are
doing.
Am I wrong, or does the Perl language literally attract the wizards of
the world to it, more than other languages? Consider the following
code someone wrote that I found on a web site:
not exp log srand xor s qq qx xor
s x x length uc ord and print chr
ord for qw q join use sub tied qx
xor eval xor print qq q q xor int
eval lc q m cos and print chr ord
for qw y abs ne open tied hex exp
ref y m xor scalar srand print qq
q q xor int eval lc qq y sqrt cos
and print chr ord for qw x printf
each return local x y or print qq
s s and eval q s undef or oct xor
time xor ref print chr int ord lc
foreach qw y hex alarm chdir kill
exec return y s gt sin sort split
Run it and see what it does. How in the world did someone come up
with this?
Who are these people?
------------------------------
Date: Sun, 04 Mar 2007 23:30:48 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Question about wizard Perl programmers
Message-Id: <x7vehgia6f.fsf@mail.sysarch.com>
>>>>> "L" == LovesHisLittleShad <jgrace5@gmail.com> writes:
L> Is it my imagination, or is Perl a million times harder than other
L> languages? Looking at books on all the languages of the past (I'm a
L> programmer), I've notices that Perl is the only one that seems greek
L> in most chapters, with very little explanation of what the people are
L> doing.
you must not be a very good programmer if perl books leave you
behind. or you are reading the wrong perl books.
L> Am I wrong, or does the Perl language literally attract the wizards of
L> the world to it, more than other languages? Consider the following
L> code someone wrote that I found on a web site:
i say the wizards recognize perl for the great language that it is. it
makes easy things easy and hard things possible. it is more fun to code
in than any other language i have known (which is too many).
L> not exp log srand xor s qq qx xor
L> s x x length uc ord and print chr
L> ord for qw q join use sub tied qx
L> xor eval xor print qq q q xor int
L> eval lc q m cos and print chr ord
L> for qw y abs ne open tied hex exp
L> ref y m xor scalar srand print qq
L> q q xor int eval lc qq y sqrt cos
L> and print chr ord for qw x printf
L> each return local x y or print qq
L> s s and eval q s undef or oct xor
L> time xor ref print chr int ord lc
L> foreach qw y hex alarm chdir kill
L> exec return y s gt sin sort split
L> Run it and see what it does. How in the world did someone come up
L> with this?
i won't run it. but you can run it through a deparser and it will be
much clearer. and that isn't production code but a perl hack. why do you
care about it?
and you can write bad code in any language. in fact, most code is badly
written as it is a skill just like any other and some people are just
better at it than others. and because coding is something a grade
schooler can start to learn and morons can get jobs in java sweat shops,
most real code is crap.
L> Who are these people?
me.
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: Sun, 4 Mar 2007 23:42:00 -0500
From: "~greg" <g_m@remove-comcast.net>
Subject: Re: Question about wizard Perl programmers
Message-Id: <3eOdnV5GnqkfAnbYnZ2dnUVZ_sOknZ2d@comcast.com>
"LovesHisLittleShad" > wrote
>
> not exp log srand xor s qq qx xor
> s x x length uc ord and print chr
> ord for qw q join use sub tied qx
> xor eval xor print qq q q xor int
> eval lc q m cos and print chr ord
> for qw y abs ne open tied hex exp
> ref y m xor scalar srand print qq
> q q xor int eval lc qq y sqrt cos
> and print chr ord for qw x printf
> each return local x y or print qq
> s s and eval q s undef or oct xor
> time xor ref print chr int ord lc
> foreach qw y hex alarm chdir kill
> exec return y s gt sin sort split
>
> ...
> Who are these people?
Dylan Thomas wrote that.
------------------------------
Date: 4 Mar 2007 20:48:35 -0800
From: "datashaping" <vincent64@yahoo.com>
Subject: Statistical software - source code available
Message-Id: <1173070115.552056.107900@p10g2000cwp.googlegroups.com>
I've made my ridge and linear multiple regression (with bootstrap to
compute confidence intervals) available to everyone, at no cost. You
can download the source code (C and Perl versions available) at
www.datashaping.com/regress.shtml
~Vincent
------------------------------
Date: Sun, 4 Mar 2007 16:09:13 -0500
From: "~greg" <g_m@remove-comcast.net>
Subject: Tk::DropSite question
Message-Id: <AbmdnclIIpj6qHbYnZ2dnUVZ_ragnZ2d@comcast.com>
I have reduced the following script,
but it's runnable. It's a way
to make a Tk listbox that accepts
a selection of files or folders
from Windows Explorer.
The drop handler (my "OnSourceDrop")
is apparently called individually
on each file or folder in a multiple selection.
And my question is,
is there any way to know when to call
a group-drop-handler,
to be called after all the individual
calls to OnSourceDrop() are finished
after a group drop?
thank you,
~greg
~~~~~~~~~~~~~~~~~~~~~~
use strict;
use warnings;
$|=1;
use Tk;
use Tk::DropSite qw(Win32);
my $Main = MainWindow->new
(
-title=>'DND'
);
my %SourceList;
my $SourceListBox = $Main->Scrolled
(
"Listbox",
-scrollbars => "osoe",
)->pack
(
-fill => 'x',
);
$SourceListBox->DropSite
(
-dropcommand => [\&OnSourceDrop,$SourceListBox],
-droptypes => 'Win32',
);
sub SourceAdd
{
my $f = shift; # file or folder
return if exists $SourceList{$f};
return if ! -e $f;
$SourceList{$f} = 1;
my $slash = -d $f ? '\\' : '';
$SourceListBox->insert('end', "$f$slash" );
$SourceListBox->yviewMoveto(1);
}
sub OnSourceDrop
{
my($widget, $selection) = @_;
my $f = $widget->SelectionGet('-selection'=>$selection,'STRING');
return if ! defined $f; # is this really necessary?
SourceAdd($f);
}
MainLoop;
------------------------------
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 193
**************************************