[26138] in Perl-Users-Digest
Perl-Users Digest, Issue: 8330 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 18 06:05:30 2005
Date: Thu, 18 Aug 2005 03:05:04 -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, 18 Aug 2005 Volume: 10 Number: 8330
Today's topics:
How to add directory to include - Newbie <leongyc@tp.edu.sg>
Re: Interfaces and Type Safety, Dynamic Typing (OOP New <vtatila@mail.student.oulu.fi>
Math::BigFloat: how to specify output format? <socyl@987jk.com.invalid>
Re: Math::BigFloat: how to specify output format? <sisyphus1@nomail.afraid.org>
Re: Math::BigFloat: how to specify output format? <sisyphus1@nomail.afraid.org>
Re: Obtaining verbose info for http transfers. <sisyphus1@nomail.afraid.org>
Re: Obtaining verbose info for http transfers. <nojunkmail@pacificwireless.com.au>
Organizing data for readability and efficiency <Mark.Seger@hp.com>
Re: Problem with Curses <babacio@free.fr>
The Perl Review 2.0 is on the presses <comdog@panix.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 18 Aug 2005 17:50:35 +0800
From: "NewBie" <leongyc@tp.edu.sg>
Subject: How to add directory to include - Newbie
Message-Id: <43045704$1@news>
Hi,
Appreciate any advice to overcome the following:
Can't locate RRDs.pm in @INC (@INC contains: /opt/orca/lib) at ./orca line
33.
BEGIN failed--compilation aborted at ./orca line 33.
Where RRDs.pm can be located in other directory.
Thanks in advance.
------------------------------
Date: Thu, 18 Aug 2005 09:10:05 +0300
From: "Veli-Pekka Tätilä" <vtatila@mail.student.oulu.fi>
Subject: Re: Interfaces and Type Safety, Dynamic Typing (OOP Newbie in Perl)
Message-Id: <de18o9$lev$1@news.oulu.fi>
Tassilo v. Parseval wrote:
<snipped heavy-handedly>
> Also sprach Veli-Pekka Tätilä:
>> Is there a good way to implement an interface in Perl or some perlish
>> idiom
> write a package where each method dies on invocation.
Ah, I see-. This semed like a crude solution until you showed the way to
make multiple methods die without repeating the bulk of the code
redundantly.
Dying is at least better than doing a pure NOP. That way you know right away
that you did something wrong. It's called defensive programming, though
sometimes Perl is not as defensive as I'd like. Again PHP is about as
defensless (is that the opposite?) as can be by default.
> That is true. Mistyped method invocations are caught at runtime. They
> have to be due to Perl's super-polymorphic nature.
Oh ok. That's still a bit nasty, considering you can force strict refs, vars
and so on, and of course normal subs canot be polymorphic so there names can
be checked at runtime just fine. But could you give me an example of a real
world project or module where dynamic typing is used to achieve something
that would be very difficult to do in a strongly and statically typed
language?
I've noticed that many OOP features appear to have very littel real-world
significance first but there are special cases in which they may be
essential. Take reflection and friend classes as examples. I was
implementing a simple XML RPC server in Java for testing purposes and
noticed that the lib I was using was able to automatically register certain
methods based on their type and name. Where as in PHP you would have to
manually fill in a method dispatch map, of course the manual way was present
in the Java implementation, too. And as for friends, I was testing some
badly written awt code with J-Unit (is there a P-Unit or something for
Perl?), and dearly wished I could just say hey gimme full access when I'm
testing. In stead I had to manually hack the code changing private parts to
public in places.
> sub func (\@) {
> "I must receive an array";
> my $ary_ref = shift; # it's passed as reference
> }
Hey thanks for this simple piece of code. I was under the impression that
you had to put a separate prototype at the top as in C, rather than
specifying it only one time in the err sub signature (compare to Java).
> Run-time checks such as isa() or ref() are the
> ones most commonly found to catch type violations.
That makes sense and is probably also sufficient for most cases. after all
it is unlikely you would assign the wrong type of reference if knowing the
class hierarchy at some level.
<module internals>
> This very liberal approach may be frowned upon by the Ada language
> designers, however each has its own virtues and shortcomings.
Agreed. Getting slightly OT in this thread again: sometimes abstraction can
be a hindrance, too. I like the fact that Perl has got regexp in the
language. If I need to do them in Java, I write and test the Perl code first
if possible.
--
With kind regards Veli-Pekka Tätilä (vtatila@mail.student.oulu.fi)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila/
------------------------------
Date: Thu, 18 Aug 2005 03:01:18 +0000 (UTC)
From: kj <socyl@987jk.com.invalid>
Subject: Math::BigFloat: how to specify output format?
Message-Id: <de0tlu$324$1@reader2.panix.com>
How can I control the output format of Math::BigFloat objects? When
I print using the bsstr method, which is supposed to express the
number in scientific notation, I get weird unnormalized numbers
like
8270427429387424792837429347E-719
instead of
8.270427429387424792837429347E-692
Thanks!
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
------------------------------
Date: Thu, 18 Aug 2005 14:07:37 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Math::BigFloat: how to specify output format?
Message-Id: <430409c2$0$24680$afc38c87@news.optusnet.com.au>
"kj" <socyl@987jk.com.invalid> wrote in message
news:de0tlu$324$1@reader2.panix.com...
>
>
>
> How can I control the output format of Math::BigFloat objects? When
> I print using the bsstr method, which is supposed to express the
> number in scientific notation, I get weird unnormalized numbers
> like
>
> 8270427429387424792837429347E-719
>
> instead of
>
> 8.270427429387424792837429347E-692
>
What you're getting is as documented. (The mantissa is always returned as an
integer, not a float.)
You could write your own adjustment subroutine to rewrite the number to the
form you want.
Something like (tested, but it may not cater properly for *all*
eventualities):
use warnings;
use Math::BigFloat;
$f = Math::BigFloat->new
("8.270427429387424792837429347E-692");
print $f->bsstr(), "\n";
print adjust($f), "\n";
sub adjust {
my @bits = $_[0]->parts();
# $bits[0] is the mantissa, $bits[1] is the exponent.
my $neg = '';
if($bits[0] =~ /\-/) {
$neg = '-';
$bits[0] =~ s/\-//;
}
$bits[1] += length($bits[0]) - 1;
if($bits[0] > 1) {
substr($bits[0], 1, 0, '.');
}
return $neg . $bits[0] . 'E' . $bits[1];
}
__END__
Cheers,
Rob
------------------------------
Date: Thu, 18 Aug 2005 14:15:27 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Math::BigFloat: how to specify output format?
Message-Id: <43040b98$0$22557$afc38c87@news.optusnet.com.au>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote in message
>
> use warnings;
> use Math::BigFloat;
>
> $f = Math::BigFloat->new
> ("8.270427429387424792837429347E-692");
>
> print $f->bsstr(), "\n";
>
> print adjust($f), "\n";
>
> sub adjust {
> my @bits = $_[0]->parts();
> # $bits[0] is the mantissa, $bits[1] is the exponent.
> my $neg = '';
> if($bits[0] =~ /\-/) {
> $neg = '-';
> $bits[0] =~ s/\-//;
> }
>
> $bits[1] += length($bits[0]) - 1;
>
Grrroooooaann ...... I meant the next line to be:
if(length($bits[0]) > 1) {
> if($bits[0] > 1) {
> substr($bits[0], 1, 0, '.');
> }
>
> return $neg . $bits[0] . 'E' . $bits[1];
> }
>
> __END__
>
There's still no guarantee that it will handle all cases as you would wish.
Cheers,
Rob
------------------------------
Date: Thu, 18 Aug 2005 12:12:38 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Obtaining verbose info for http transfers.
Message-Id: <4303eed1$0$21235$afc38c87@news.optusnet.com.au>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
[snip]
> Web Scraping Proxy
>
> http://www.research.att.com/~hpk/wsp/
>
That, and the advice offered by other respondents, gives me something to
work with. Thanks, guys.
[snip]
>
> Spyware would provide those symptoms too...
>
Yes - I have some anti-spyware software (Spybot - Search and Destroy) which
claims to be finding and removing spyware. But it never seems to make much
difference.
As an example, it took at least 15 seconds (more like 20 seconds) for
Internet Explorer to download:
http://sourceforge.net/cvs/?group_id=612 .
LWP::UserAgent took 7 seconds. Perhaps that difference is to be expected. I
know so little of what's going on that I really don't know - but I feel it's
about time I took steps to find out :-)
Cheers,
Rob
------------------------------
Date: Thu, 18 Aug 2005 15:39:43 +1000
From: "Leigh Sharpe" <nojunkmail@pacificwireless.com.au>
Subject: Re: Obtaining verbose info for http transfers.
Message-Id: <1124343553.894596@ns1.pacificwireless.com.au>
> It's not uncommon for my browser to take 15-20 seconds to download a web
> page that doesn't contain a lot of data (a few small pictures, an
> advertisement or 2, maybe more than one frame, but not much in terms of
> overall data to be transferred) - which implies that if this is explained
in
> terms of the aforementioned latency, then there's quite a few messages
going
> back and forth. (A ping of a remote site takes about 1.3 seconds.)
A ping of 1.3 seconds is pretty slow. Most people regard >500mS to be
unacceptable, even on 33.6k dial-up.
I'd be doing a traceroute to find out where the bottleneck is first. If it's
in your first hop, then you can pretty much guarantee that your first
assumption about latency is right.
------------------------------
Date: Thu, 18 Aug 2005 01:40:16 -0400
From: Mark Seger <Mark.Seger@hp.com>
Subject: Organizing data for readability and efficiency
Message-Id: <43041f42$1@usenet01.boi.hp.com>
I know this can be a very long, complex topic and am hoping by using a
specific example can keep things more focused, but I also suspect not. 8-)
Anyhow I've put together a script for generating a variety of plots
using perl/Tk from a set of tables. Each table describes what a plot
looks like, for example its title, Y-acess limits, the variables it can
plot, etc.
To get things going quickly, I stored each in a array named for what the
data is and indexed by the plot number. So $title[0] is the title of
the first plot, $ymax[2] is upper bound of the yaxis of the 3rd, etc.
While easy to understand there are too many arrays to pass around to
various routines and I have therefore made them all globals.
What I'm now looking for are alternatives data organizations that could
allow me to store all the information in a single data structure that
could be passed to different routines but still be easily readable as
well as efficient.
One option, that I rejected, was to have an array of arrays such that
$plot[2][3] could be the data for the 3rd plot, and the 3 could indicate
it as the lower limit of the $yaxis. While pretty simple to implement,
this would require a scorecard to understand it. I could always have
some constants like $TITLE and use them as index, but am not sure
whether or not I want to do that.
Another alternative would be to have a hash of arrays such that each
hash entry could itself be an array (I'm not entirely sure of the
terminology here having only recently been reading about this technique)
and then I could refer to the data elements as something like
$plot{'title'}->[2] to refer to the title of the 3rd plot and could
simply pass around a reference to %plot. I like this organization but
also suspect there are a variety of purmutations of this methodology and
how one might do this and maintain good performance.
In any event, as I said in the beginning I'd be interested in people's
thoughts on this topic and how they might choose to organize things for
ease of maintenance (my code tends to be more verbose for clarity) as
well as performance.
sorry for being so long winded...
-mark
------------------------------
Date: Thu, 18 Aug 2005 08:35:25 +0200
From: Babacio <babacio@free.fr>
Subject: Re: Problem with Curses
Message-Id: <m2r7cr92he.fsf@baba.ba>
Ian Wilson.
> $ uname
> Linux
> $ ./curses.pl
> Can't locate curses.pm in @INC
>
> Maybe you should say where you got Curses.pm and which version you are
> using?
Curses is available from the CPAN.
But for some curious reason, my version that I installed form
darwinports is 1.08. I'll try to install the last one which is 1.12.
Anyway, the problem is more likely to be linked with the binary
lib...
--
Bé erre hue ixe eu elle, Bruxelles.
------------------------------
Date: Wed, 17 Aug 2005 20:18:05 -0500
From: brian d foy <comdog@panix.com>
Subject: The Perl Review 2.0 is on the presses
Message-Id: <170820052018055786%comdog@panix.com>
We're starting the next year of The Perl Review, which comes out
during the first week of September. We're also printing a batch in
Portugal, so attendees of YAPC::EU will get a free copy of the
next issue, which is bigger and more colorful than ever before.
If you haven't subscribed, now's the time to get your name on the
list. If you're a subscriber who hasn't renewed, do so now or risk
missing an issue.
TPR is the only print magazine devoted to Perl.
http://www.theperlreview.com/
Issue 2.0, Fall 2005
* Logic Programming in Perl - Curtis "Ovid" Poe
* Object-oriented Perl - Alberto Manuel Simões
* The Visitor Design Pattern - brian d foy
* Pod Indexing Project - Ivan Tubert-Broham
* TPF: Google Summer of Code - Jim Brandt
plus Perl News, Perl Mongers and Perl Foundation reports, book
reviews, short notes, and more.
Interviews (available on the website for free):
Josh McAdams - Perlcast
Damian Conway - Perl Best Practices
Simon Cozens - Advanced Perl Programming
Mark Jason Dominus - Higher Order Perl
-------------------------------------------------------------------------
Issue 1.3, Summer 2005
* Programming Glade in Perl - Grant McLean
* Array Anti-Patterns - Alberto Manuel Simões
* Test::Random - David Golden
* Serious Perl - Henning Koch
plus Perl News, Perl Mongers and Perl Foundation reports, book
reviews, short notes, and more.
-------------------------------------------------------------------------
Issue 1.2, Spring 2005
* Hashes with History -- Alberto Manuel Simões
* Test::Number::Delta -- David Golden
* 9-Block Quilt Patterns in Perl -- Daniel Allen
* Packet Sniffing with Perl -- Gerry Finkel
plus Perl News, Perl Mongers and Perl Foundation reports, book
reviews, short notes, and more.
-------------------------------------------------------------------------
Issue 1.1, Winter 2004
* Down Translating XML -- Alberto Manuel Simões
* Module::Release and Beyond -- brian d foy
* Functional Perl Programming -- Frank Antonsen
* Faking Stored Procedures -- Zach Thompson
plus Perl News, Perl Mongers and Perl Foundation reports, book
reviews, and short notes.
-------------------------------------------------------------------------
The first print issue ( 1.0 ) is still available to subscribers online
as a PDF file, and some back issues are available.
* Test Driven Development -- Denis Kosykh
* Just do{} it -- brian d foy
* Extending XML::XPath -- Michel Rodriguez
* Test::More in 20 Seconds -- brian d foy
* Magick Tile Puzzles -- Grant McLean
Before that, The Perl Review was a digital only version with
eight issues which are still available for free download as
PDF files.
http://www.theperlreview.com/Issues/
-------------------------------------------------------------------------
RSS Feeds are available too.
Subscriber only (current) issues
http://www.theperlreview.com/RSS/tpr-subscribers.rdf
Free Issues and articles
http://www.theperlreview.com/RSS/tpr-free.rdf
The Perl Review news
http://www.livejournal.com/users/perl_review/data/rss
The Perl Review public discussion
http://www.livejournal.com/community/the_perl_review/data/rss
-------------------------------------------------------------------------
Want to write for TPR? Send us a note, or submit an idea online
http://www.theperlreview.com/Authors/submit.html
-------------------------------------------------------------------------
Prices: $16 in the US, $30 outside the US. Web only subscriptions
are $16. If we can get enough subscribers in the European Union, we'll
start printing there too and lower the cost. If you like, you can
start your subscription with the Winter 2004 issue and save money
by not having to buy the back issues later.
TPR accepts MasterCard, Visa, American Express, PayPal, Amazon.com
Honors System, and check or money order in US dollars. Sorry, but we
can only accept advance payment since we're too small to do handle
individual billing.
Samples to Perl user groups, Perl instructors, and other worthy causes
are available.
--
brian d foy, bdfoy@cpan.org
Subscribe to The Perl Review: http://www.theperlreview.com
------------------------------
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 8330
***************************************