[29328] in Perl-Users-Digest
Perl-Users Digest, Issue: 572 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 25 09:10:11 2007
Date: Mon, 25 Jun 2007 06:09:10 -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 Mon, 25 Jun 2007 Volume: 11 Number: 572
Today's topics:
Re: Assigning another filehandle to STDOUT, using binmo <a24061@ducksburg.com>
Re: Assigning another filehandle to STDOUT, using binmo <a24061@ducksburg.com>
Re: Assigning another filehandle to STDOUT, using binmo <a24061@ducksburg.com>
Re: Assigning another filehandle to STDOUT, using binmo <a24061@ducksburg.com>
fedora core 5 + install net::ssh::perl = hangs <luc2@nospam.invalid>
Re: fedora core 5 + install net::ssh::perl = hangs <noreply@gunnar.cc>
Re: How can I overload the build in array type? <ilias@lazaridis.com>
new CPAN modules on Mon Jun 25 2007 (Randal Schwartz)
Re: Passing function references in the constructor <paduille.4061.mumia.w+nospam@earthlink.net>
Re: Portable general timestamp format, not 2038-limited (Robert Maas, see http://tinyurl.com/uh3t)
Re: Portable general timestamp format, not 2038-limited <see_website@mindprod.com.invalid>
Re: The Modernization of Emacs <lars.spam@nocrew.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 25 Jun 2007 11:13:13 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <p2h4l4-uqk.ln1@news.ducksburg.com>
On 2007-06-22, Mumia W. wrote:
>> As I said, I'm running the program in a UTF-8 environment but getting
>> thousands (I think) of identical warnings about "Wide characters"
>> which actually refer to correct UTF-8 characters that Perl has read
>> from input data files without a hiccup.
>>
>> Why is it unreasonable that I find this annoying?
>> or
>> What am I doing that constitutes an error?
>
> You probably are assuming that open() configures your filehandles with
> binmode() for you. This isn't true.
>
> If you open a file, and it needs a special encoding,
By "special" you mean "anything other than ASCII, right?
> you need to call
> binmode(). If you close and re-open STDOUT, you need to call binmode()
> on it (if it needs encoding). If you close and re-open STDOUT when it's
> aliased as OUTPUT, you still need to set up the encoding.
>
> When you need an encoding, it's your responsibility to use binmode() to
> set it on each file handle. The only exception I'm aware of is when the
> "encoding" module is used. But that only sets up STDIN and STDOUT, and
> it only sets them once. Even if the encoding pragma is used, if STDOUT
> is closed and re-opened, binmode() must be called on it again.
OK, thanks.
------------------------------
Date: Mon, 25 Jun 2007 11:18:32 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <och4l4-uqk.ln1@news.ducksburg.com>
On 2007-06-22, John W. Krahn wrote:
> Mumia W. wrote:
>> You probably are assuming that open() configures your filehandles with
>> binmode() for you. This isn't true.
>
> You mean like:
>
> open FH, '<:raw', 'filename';
>
> ??
But to be fair to Mumia, the "simpler" form of open() doesn't do that,
and I was expressing surprise that open() didn't assume the
environment locale to be applicable.
Is there any difference between
open(OUTPUT, '>:utf8', $output_filename);
and
open(OUTPUT, ">" . $output_filename);
binmode (OUTPUT, ":utf8");
or should I just use whichever one I find more aesthetic?
------------------------------
Date: Mon, 25 Jun 2007 11:22:13 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <ljh4l4-uqk.ln1@news.ducksburg.com>
On 2007-06-22, Klaus wrote:
>> OK, let my try a different set of questions: is using binmode the
>> correct way to fix the error that causes those warnings?
>>
>> As I said, I'm running the program in a UTF-8 environment but getting
>> thousands (I think) of identical warnings about "Wide characters"
>> which actually refer to correct UTF-8 characters that Perl has read
>> from input data files without a hiccup.
> try perl -C7
>
> see perldoc perlrun:
Since I'm sometimes using output other than STDOUT, I think I need the
more comprehensive -C31 (equivalent to IOEio). Thanks.
------------------------------
Date: Mon, 25 Jun 2007 11:28:45 +0100
From: Adam Funk <a24061@ducksburg.com>
Subject: Re: Assigning another filehandle to STDOUT, using binmode.
Message-Id: <tvh4l4-uqk.ln1@news.ducksburg.com>
On 2007-06-23, Peter J. Holzer wrote:
> It is "a" correct way, not "the" correct way. There are other ways: The
> -C option (and it's cousin, the PERL_UNICODE environment variable),
> specifying perl I/O layers for open, etc.
>
> I generally prefer
>
> open($fh, '<:utf8', $filename);
>
> to
>
> open($fh, '<', $filename);
> binmode $fh, ':utf8';
>
> because it is shorter and cleaner. So I use binmode only on STDIN,
> STDOUT and (rarely) STDERR, and then I might use -C instead.
As far as I can tell, I'm not getting errors or warnings reading the
input files (but I'm not doing it directly with my own code --- I'm
using XML::Twig's parsefile($input_filename) method; the input files
are XML with Cyrillic UTF-8 PCDATA) --- does Perl by default take the
environment into consideration, or assume UTF-8, for input but not
output?
------------------------------
Date: 25 Jun 2007 10:32:04 GMT
From: luc2 <luc2@nospam.invalid>
Subject: fedora core 5 + install net::ssh::perl = hangs
Message-Id: <slrnf7v6n9.vsn.luc2@localhost.localdomain>
hello,
when trying to install net::ssh::perl on fedora core 5, it hangs at this
step :
t/03-packet......ok 1/10
i don't know if it hangs on other distributions... it's a known problem,
it seems to be a fix in version 1.30, but precisely, it's the version
1.30 i'm trying to install, and it hangs...
i'm sure one of you has already encountered this problem, and holds the
solution.
------------------------------
Date: Mon, 25 Jun 2007 14:32:33 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: fedora core 5 + install net::ssh::perl = hangs
Message-Id: <5e9r4hF36jbrgU1@mid.individual.net>
luc2 wrote:
... separate messages to at least three Usenet groups. Please don't do
that!!
http://lipas.uwasa.fi/~ts/http/crospost.html
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Mon, 25 Jun 2007 02:41:46 -0000
From: Ilias Lazaridis <ilias@lazaridis.com>
Subject: Re: How can I overload the build in array type?
Message-Id: <1182739306.819120.317340@w5g2000hsg.googlegroups.com>
On Jun 24, 6:14 pm, Michael Carman <mjcar...@mchsi.com> wrote:
> On 6/23/2007 9:33 PM, Ilias Lazaridis wrote:
>
> > On Jun 23, 5:13 pm, Michael Carman wrote:
> >> On 6/22/2007 3:09 AM, Ilias Lazaridis wrote:
>
> >>> is there a similar module to overload the classes of build in types
>
> >> You can't overload sigils but you can use tie() to create your own
> >> implementation of the built in data types.
>
> > [This] does not seem to be the construct I am searching for (I would
> > need a one-liner per module to activate the change, e.g. something
> > like "use oveloadarray".
>
> Overloading works because Perl knows what class a variable has been blessed
[...] - (other construct)
> > The most important use case would be to enable array pointer creation
>
> > my $data = []; # assigns an "My::Array" pointer
>
> my $data = [];
> tie @$data, 'My::Array';
I am looking for a construct which is importable, e.g.
use UseMyArray;
within "UseMyArray" i do the relevant things, thus "[]" returns an
reference to an "My::Array" instance, instead of a reference to an
perl array.
> Or, if you want to be Lazy:
> package My::Array;
[...] - (obvious OO implementation)
> > The direct "sigil overload" has 2nd priority:
>
> > my @data; # isa "My::Array"
>
> tie my @data, 'My::Array';
same as above.
> Is there a reason that won't work for you? If you're really obsessed with
> this you could probably write a source filter to do it, but I wouldn't
> recommend it as anything other than a learning exercise.
=> probably a "source filter" can solve the problem.
ok, thank you!
I assume the source filter would just replace the "[<construction
data>]" with "My::Array->new(<construction data>).
Thus a perl "source filter" is something like a "custom preprocessor"
or "custom macro".
No problem, I could use such a construct (if no other is available).
Are there any technical(!) negative issues with "source filters" ?
.
--
http://dev.lazaridis.com/lang/ticket/17
------------------------------
Date: Mon, 25 Jun 2007 04:42:16 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jun 25 2007
Message-Id: <JK6D2G.qt8@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.
Apache-Auth-Subrequest-v0.0.1
http://search.cpan.org/~scott/Apache-Auth-Subrequest-v0.0.1/
Allow only if a Subrequest !
----
Apache-Image-v0.0.4
http://search.cpan.org/~scott/Apache-Image-v0.0.4/
Generate a new image size, e.g. Thumbnail on the fly of any image, even dynamically generated (EXPERIMENTAL RELEASE)
----
CGI-ContactForm-1.42
http://search.cpan.org/~gunnar/CGI-ContactForm-1.42/
Generate a web contact form
----
Catalyst-Plugin-Session-0.15
http://search.cpan.org/~nuffin/Catalyst-Plugin-Session-0.15/
Generic Session plugin - ties together server side storage and client side state required to maintain session data.
----
DBIx-Class-UUIDColumns-0.02000
http://search.cpan.org/~claco/DBIx-Class-UUIDColumns-0.02000/
Implicit uuid columns
----
DBIx-Class-Validation-0.02000
http://search.cpan.org/~claco/DBIx-Class-Validation-0.02000/
Validate all data before submitting to your database.
----
Device-Modem-1.48
http://search.cpan.org/~cosimo/Device-Modem-1.48/
Perl extension to talk to modem devices connected via serial port
----
Filter-EOF-0.03
http://search.cpan.org/~phaylon/Filter-EOF-0.03/
Run a callback after a file has been compiled
----
Geo-Google-0.04
http://search.cpan.org/~allenday/Geo-Google-0.04/
Perform geographical queries using Google Maps
----
HTML-Breadcrumbs-0.7
http://search.cpan.org/~gavinc/HTML-Breadcrumbs-0.7/
module to produce HTML 'breadcrumb trails'.
----
HTTP-Server-Brick-0.0.5
http://search.cpan.org/~aufflick/HTTP-Server-Brick-0.0.5/
Simple pure perl http server for prototyping "in the style of" Ruby's WEBrick
----
HTTP-Server-Brick-0.0.6
http://search.cpan.org/~aufflick/HTTP-Server-Brick-0.0.6/
Simple pure perl http server for prototyping "in the style of" Ruby's WEBrick
----
HTTP-Server-Brick-0.0.7
http://search.cpan.org/~aufflick/HTTP-Server-Brick-0.0.7/
Simple pure perl http server for prototyping "in the style of" Ruby's WEBrick
----
Handel-1.00000
http://search.cpan.org/~claco/Handel-1.00000/
A cart/order/checkout framework with AxKit/TT/Catalyst support
----
Handel-Storage-RDBO-1.00000
http://search.cpan.org/~claco/Handel-Storage-RDBO-1.00000/
RDBO storage layer for Handel 1.x
----
IWL-0.45
http://search.cpan.org/~viktork/IWL-0.45/
A widget library for the web
----
List-Filter-0.03
http://search.cpan.org/~doom/List-Filter-0.03/
named, persistent, shared lists of patterns
----
Module-ScanDeps-0.75
http://search.cpan.org/~smueller/Module-ScanDeps-0.75/
Recursively scan Perl code for dependencies
----
Net-MRIM-0.1
http://search.cpan.org/~aau/Net-MRIM-0.1/
Perl implementation of mail.ru agent protocol
----
Net-MRIM-0.2
http://search.cpan.org/~aau/Net-MRIM-0.2/
Perl implementation of mail.ru agent protocol
----
Net-MRIM-0.3
http://search.cpan.org/~aau/Net-MRIM-0.3/
Perl implementation of mail.ru agent protocol
----
Object-Recorder-0.01
http://search.cpan.org/~nilsonsfj/Object-Recorder-0.01/
Records method calls into a serializable data structure
----
PAR-Dist-0.23
http://search.cpan.org/~smueller/PAR-Dist-0.23/
Create and manipulate PAR distributions
----
Pod-Tree-1.15
http://search.cpan.org/~swmcd/Pod-Tree-1.15/
Create a static syntax tree for a POD
----
Runops-Trace-0.06
http://search.cpan.org/~jjore/Runops-Trace-0.06/
Trace your program's execution
----
Statistics-Lite-3.2
http://search.cpan.org/~brianl/Statistics-Lite-3.2/
Small stats stuff.
----
Test-GreaterVersion-0.004
http://search.cpan.org/~ggoldbach/Test-GreaterVersion-0.004/
Did you update the VERSION?
----
Test-Run-0.0112
http://search.cpan.org/~shlomif/Test-Run-0.0112/
----
Text-CSV_PP-Iterator-1.00
http://search.cpan.org/~rsavage/Text-CSV_PP-Iterator-1.00/
Provide fetchrow_hashref() for CSV files
----
XML-Bare-0.11
http://search.cpan.org/~codechild/XML-Bare-0.11/
Minimal XML parser implemented via a C state engine
----
YAML-LibYAML-0.24
http://search.cpan.org/~ingy/YAML-LibYAML-0.24/
----
YAML-LibYAML-0.25
http://search.cpan.org/~ingy/YAML-LibYAML-0.25/
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: Mon, 25 Jun 2007 05:02:05 GMT
From: "Mumia W." <paduille.4061.mumia.w+nospam@earthlink.net>
Subject: Re: Passing function references in the constructor
Message-Id: <h%Hfi.766$rR.693@newsread2.news.pas.earthlink.net>
On 06/24/2007 03:52 PM, koszalekopalek@interia.pl wrote:
> Hello,
>
> I would like to create a number of objects of the same class (mypack)
> and specify a reference to a function in the constructor. I would like
> to
> let the module user either use a predefined function (e.g. test1)
> provided in the class or let him write his own function and provide
> a reference to it in the constructor.
>
> The example below does just that.
>
> I create object $obj1 of class mypack and use a predefined sub test1.
> Then I create $obj2 and pass a reference to a custom function
> customtest.
>
> The problem is that the two functions
> $obj1->riddle (1, 2, 3);
> and
> $obj2->riddle (1, 2, 3);
> receive different arguments depending on where they come from.
> The first argument passed to the function test1 is the name of the
> class (and then comes the number, i.e. 1). If it is customtest, it
> does
> not get the name of the class.
>
>
> This is the output of the attached program:
> ---- test1 args ----
> mypack
> 1
> ---- customtest args ----
> 1
> 2
>
> What would be the most elegant way to tackle this problem? I'd
> rather
> not shift arguments in test1 or do anything like that. Maybe there
> is
> a better way to pass function references in the constructor?
>
>
> #!/usr/bin/perl
>
These lines are missing:
use strict;
use warnings;
Modifying your program to work under these conditions will help you
catch many errors.
> {
> package mypack;
>
> sub new {
> my $class = shift;
> $self = { @_ };
> bless $self, $class;
> return $self;
> };
>
> sub riddle {
> my $self = shift;
> my $testref = \&test;
> my $testref = $self->{fun};
> &$testref (@_);
> };
>
>
> sub test1 {
> print "---- test1 args ----\n";
> print @_[0], "\n";
> print @_[1], "\n";
> };
>
Since you don't do "my $self = shift;", test is not expected to be a
method, but a normal function--which is okay.
>
>
> };
>
>
> sub customtest {
> print "---- customtest args ----\n";
> print @_[0], "\n";
> print @_[1], "\n";
> }
>
>
> my $obj1 = mypack->new(
> fun => sub { mypack->test1 (@_) }
> );
But here, you invoke 'test' as a class method of the 'mypack' package.
Change that line to the following, and you'll get better results:
fun => sub { test1(@_) }
Or try this:
fun => \&mypack::test1
> $obj1->riddle (1, 2, 3);
>
>
> my $obj2 = mypack->new(
> fun => \&customtest
> );
> $obj2->riddle (1, 2, 3);
>
There are several more problems with your program. Let strictures (use
strict) and warnings (use warnings) tell you about them.
Just by fixing the problems reported by "use strict;" and "use
warnings;", I was able to create an improved version of your program:
#!/usr/bin/perl
use strict;
use warnings;
package Mypack;
sub new {
my $class = shift;
my $self = { @_ };
bless $self, $class;
return $self;
}
sub riddle {
my $self = shift;
my $testref = \&test1;
if ($self->{fun}) { $testref = $self->{fun}; }
&$testref (@_);
}
sub test1 {
print "---- test1 args ----\n";
print $_[0], "\n";
print $_[1], "\n";
}
package main;
sub customtest {
print "---- customtest args ----\n";
print $_[0], "\n";
print $_[1], "\n";
}
my $obj1 = Mypack->new();
my $obj2 = Mypack->new(
fun => \&customtest
);
$obj1->riddle(1, 2, 3);
$obj2->riddle(1, 2, 3);
------------------------------
Date: Sun, 24 Jun 2007 18:14:08 -0700
From: rem642b@yahoo.com (Robert Maas, see http://tinyurl.com/uh3t)
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <rem-2007jun24-006@yahoo.com>
> From: James Harris <james.harri...@googlemail.com>
> I have a requirement to store timestamps in a database. ...
> 1) subsecond resolution - milliseconds or, preferably, more detailed
How do you plan to deal with leap seconds?
- Stick to astronomical time, which is absolutely consistent but
which drifts from legal time?
- Stick to legal time (UTC), which stalls by one second from time
to time, causing time-difference calculations to be incorrect by
varying numbers of seconds?
Only after you make *that* crucial decision, will it be reasonable
to consider milliseconds or other sub-second resolution.
As for the representation to store in the DB, somebody suggested
text, and I agree, with one clarification: Stick to US-ASCII, which
has been incorporated into UniCode hence is pretty much guaranteed
to be stable for longer than you care about.
------------------------------
Date: Mon, 25 Jun 2007 11:17:27 GMT
From: Roedy Green <see_website@mindprod.com.invalid>
Subject: Re: Portable general timestamp format, not 2038-limited
Message-Id: <u09v735nhaofje1064grpcf4fd4cgl080i@4ax.com>
On Sun, 24 Jun 2007 18:14:08 -0700, rem642b@yahoo.com (Robert Maas,
see http://tinyurl.com/uh3t) wrote, quoted or indirectly quoted
someone who said :
>- Stick to astronomical time, which is absolutely consistent but
> which drifts from legal time?
depends what you are measuring. IF you are doing astronomy, your
advice would apply. If you are doing payrolls, you want effectively to
pretend the leap seconds never happened, just as Java does.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
------------------------------
Date: Mon, 25 Jun 2007 13:54:41 +0200
From: Lars Brinkhoff <lars.spam@nocrew.org>
Subject: Re: The Modernization of Emacs
Message-Id: <85hcownta6.fsf@junk.nocrew.org>
David Kastrup <dak@gnu.org> writes:
> I should think that version 2.3.1 would not even try ftp. Is that
> on Multics?
Note that the GNU Emacs version jumped directly from 1.12 to 13.
See etc/ONEWS.1.
------------------------------
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 572
**************************************