[31534] in Perl-Users-Digest
Perl-Users Digest, Issue: 2793 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 21:09:53 2010
Date: Wed, 27 Jan 2010 18:09:39 -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 Wed, 27 Jan 2010 Volume: 11 Number: 2793
Today's topics:
How to install Math::BigInt::GMP? <here@softcom.net>
Re: How to install Math::BigInt::GMP? <ben@morrow.me.uk>
Re: How to install Math::BigInt::GMP? <jimsgibson@gmail.com>
Inconsistent results from (dos)glob <tcmvandenheuvel@gmail.com>
Re: Inconsistent results from (dos)glob <ben@morrow.me.uk>
Re: Inconsistent results from (dos)glob <tcmvandenheuvel@gmail.com>
Re: Inconsistent results from (dos)glob <ben@morrow.me.uk>
Module name access <user@example.net>
Re: Module name access <No_4@dsl.pipex.com>
Re: Module name access <uri@StemSystems.com>
Re: Module name access <ben@morrow.me.uk>
Re: permalink to latest devel release of perl? <ben@morrow.me.uk>
Re: print array with separator? <ben@morrow.me.uk>
Re: print array with separator? <derykus@gmail.com>
Re: print array with separator? <derykus@gmail.com>
Re: print array with separator? <uri@StemSystems.com>
Re: print array with separator? <ben@morrow.me.uk>
Re: When to use "use strict;"? <ben@morrow.me.uk>
Re: When to use "use strict;"? <john@castleamber.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 27 Jan 2010 15:17:45 -0800 (PST)
From: Sal <here@softcom.net>
Subject: How to install Math::BigInt::GMP?
Message-Id: <0d8c120e-1fdb-4312-a979-859ffa604ad0@n4g2000yqf.googlegroups.com>
I would like to use Math::BigInt::GMP with my ActivePerl v 5.10 but it
doesn't appear in the ppm list. Can someone tell me how to get it?
------------------------------
Date: Wed, 27 Jan 2010 23:56:05 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to install Math::BigInt::GMP?
Message-Id: <ld0737-b0v.ln1@osiris.mauzo.dyndns.org>
Quoth Sal <here@softcom.net>:
> I would like to use Math::BigInt::GMP with my ActivePerl v 5.10 but it
> doesn't appear in the ppm list. Can someone tell me how to get it?
Add http://cpan.uwinnipeg.ca/PPMPackages/10xx/ as a PPM repository.
Ben
------------------------------
Date: Wed, 27 Jan 2010 16:05:04 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: How to install Math::BigInt::GMP?
Message-Id: <270120101605045366%jimsgibson@gmail.com>
In article
<0d8c120e-1fdb-4312-a979-859ffa604ad0@n4g2000yqf.googlegroups.com>, Sal
<here@softcom.net> wrote:
> I would like to use Math::BigInt::GMP with my ActivePerl v 5.10 but it
> doesn't appear in the ppm list. Can someone tell me how to get it?
I've got it (version 1.24) in my ActivePerl v.5.10.0. It looks like its
available from the repository <http://cpan.uwinnipeg.ca>. Do you have
that one in your list of repositories?
Edit -> Preferences -> Repositories -> Suggested (UWinnipeg) -> Add in
your Perl Package Manager (ppm).
--
Jim Gibson
------------------------------
Date: Wed, 27 Jan 2010 15:07:14 -0800 (PST)
From: Theo van den Heuvel <tcmvandenheuvel@gmail.com>
Subject: Inconsistent results from (dos)glob
Message-Id: <b2cc856d-e61e-489d-af6f-22179c9ee259@j14g2000yqm.googlegroups.com>
Hi,
The following script behaves differently on two Windows machines, one
XP with v5.10.0, the other Vista with v5.10.1. Here is the script:
<script>
#!/usr/bin/perl
use strict;
use warnings;
use FindBin qw($Bin);
# use File::DosGlob 'glob';
my $subdir = "$Bin/FIResources";
my @file = <"$subdir/*">;
my @file_again = glob("\"$subdir\"/*");
print "angular: ", join(', ', @file), "\n";
print "glob: ", join(', ', @file_again), "\n";
</script>
On XP the script lists the files in both print statements. On that
system the path
contains spaces (I know, not my idea).
The Vista directory does not contain spaces, but both arrays remain
empty.
Any suggestions?
Thanks
Theo van den Heuvel
------------------------------
Date: Wed, 27 Jan 2010 23:53:12 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Inconsistent results from (dos)glob
Message-Id: <880737-b0v.ln1@osiris.mauzo.dyndns.org>
Quoth Theo van den Heuvel <tcmvandenheuvel@gmail.com>:
>
> The following script behaves differently on two Windows machines, one
> XP with v5.10.0, the other Vista with v5.10.1. Here is the script:
>
> <script>
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> use FindBin qw($Bin);
> # use File::DosGlob 'glob';
>
> my $subdir = "$Bin/FIResources";
> my @file = <"$subdir/*">;
> my @file_again = glob("\"$subdir\"/*");
> print "angular: ", join(', ', @file), "\n";
> print "glob: ", join(', ', @file_again), "\n";
>
> </script>
>
> On XP the script lists the files in both print statements. On that
> system the path
> contains spaces (I know, not my idea).
> The Vista directory does not contain spaces, but both arrays remain
> empty.
>
> Any suggestions?
Have you verified that FindBin is working properly (it doesn't always)
and that the FIResources directory actually exists?
Do you have read permission (or whatever permission is required on Win32
to call readdir) on the directory? What do you get if you call
opendir/readdir directly?
Ben
------------------------------
Date: Wed, 27 Jan 2010 17:11:19 -0800 (PST)
From: Theo van den Heuvel <tcmvandenheuvel@gmail.com>
Subject: Re: Inconsistent results from (dos)glob
Message-Id: <feaae092-9ed5-4d0d-ba81-98a66d09eb91@b10g2000yqa.googlegroups.com>
On 28 jan, 00:53, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth Theo van den Heuvel <tcmvandenheu...@gmail.com>:
>
>
> > The following script behaves differently on two Windows machines, one
> > XP with v5.10.0, the other Vista with v5.10.1. Here is the script:
>
> > <script>
>
> > Any suggestions?
>
> Have you verified that FindBin is working properly (it doesn't always)
> and that the FIResources directory actually exists?
>
> Do you have read permission (or whatever permission is required on Win32
> to call readdir) on the directory? What do you get if you call
> opendir/readdir directly?
>
> Ben
Hi Ben,
FindBin was working properly and there is no difference in permissions
that I am aware of.
I added:
opendir(my $dir, $subdir) or die "can't opendir $subdir: $!";
my @file_yetagain = readdir($dir);
print "readdir: ", join(', ', @file_yetagain), "\n";
closedir $dir;
and that works okay on both platforms. That proves that the files are
really there.
I am still stumped on how the script can fail on the second machine.
Thanks,
Theo
------------------------------
Date: Thu, 28 Jan 2010 01:25:34 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Inconsistent results from (dos)glob
Message-Id: <el5737-6dv.ln1@osiris.mauzo.dyndns.org>
Quoth Theo van den Heuvel <tcmvandenheuvel@gmail.com>:
> On 28 jan, 00:53, Ben Morrow <b...@morrow.me.uk> wrote:
> > Quoth Theo van den Heuvel <tcmvandenheu...@gmail.com>:
> >
> > > The following script behaves differently on two Windows machines, one
> > > XP with v5.10.0, the other Vista with v5.10.1. Here is the script:
> >
> > > <script>
> >
> > > Any suggestions?
> >
> > Have you verified that FindBin is working properly (it doesn't always)
> > and that the FIResources directory actually exists?
> >
> > Do you have read permission (or whatever permission is required on Win32
> > to call readdir) on the directory? What do you get if you call
> > opendir/readdir directly?
>
> FindBin was working properly and there is no difference in permissions
> that I am aware of.
>
> I added:
>
> opendir(my $dir, $subdir) or die "can't opendir $subdir: $!";
> my @file_yetagain = readdir($dir);
> print "readdir: ", join(', ', @file_yetagain), "\n";
> closedir $dir;
>
> and that works okay on both platforms. That proves that the files are
> really there.
Then I'm afraid you need to go grubbing around in File::DosGlob adding
debug statements until you find where the problem is (or use the
debugger, if that's your cup of tea).
Ben
------------------------------
Date: Wed, 27 Jan 2010 19:45:39 -0500
From: monkeys paw <user@example.net>
Subject: Module name access
Message-Id: <O-mdnUt0i-bcQ_3WnZ2dnUVZ_oOdnZ2d@insightbb.com>
if we have a package and want to access the package name
using a perl var how is it done? I want the error message
to say (literally): "Mypack Error: hello, i am an error"
I want the error method to prepend "Mypack Error: " to any
error return. However, i don't want to manually enter the Mypack
string, i want to access thru $self or some such thing. How would
i do that
package Mypack;
use strict;
sub new {
my ($class, %opts) = @_;
my $self = \%opts;
bless $self, $class; # quicker than the foreach [BP - 16 Sep 2009]
$self->{error} = 'hello, i am an error';
return $self;
}
sub error {
my ($self, %opts) = @_;
# I would like to do something *like*
# return $self->{package} . 'Error: ' . $self->{error}
return 'Mypack Error: ' . $self->{error};
}
------------------------------
Date: Thu, 28 Jan 2010 00:50:38 +0000
From: Big and Blue <No_4@dsl.pipex.com>
Subject: Re: Module name access
Message-Id: <utSdnZGQP9PDQv3WnZ2dnUVZ8kti4p2d@pipex.net>
On 01/28/10 00:45, monkeys paw wrote:
> if we have a package and want to access the package name
> using a perl var how is it done?
my $package_name = __PACKAGE__;
or just interpolate __PACKAGE__ into the string.
It's like __FILE__ and __LINENO__.
> return 'Mypack Error: ' . $self->{error};
return __PACKAGE__ . ' Error: ' . $self->{error};
--
Just because I've written it doesn't mean that
either you or I have to believe it.
------------------------------
Date: Wed, 27 Jan 2010 19:55:43 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Module name access
Message-Id: <87ockf3v5c.fsf@quad.sysarch.com>
>>>>> "mp" == monkeys paw <user@example.net> writes:
mp> if we have a package and want to access the package name
mp> using a perl var how is it done? I want the error message
mp> to say (literally): "Mypack Error: hello, i am an error"
perldoc -f ref
perldoc Carp
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 28 Jan 2010 01:22:28 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Module name access
Message-Id: <kf5737-6dv.ln1@osiris.mauzo.dyndns.org>
Quoth Big and Blue <No_4@dsl.pipex.com>:
> On 01/28/10 00:45, monkeys paw wrote:
> > if we have a package and want to access the package name
> > using a perl var how is it done?
>
> my $package_name = __PACKAGE__;
>
> or just interpolate __PACKAGE__ into the string.
The __FOO__ literals don't interpolate. CLASS will give you $CLASS,
which does. (Why it's $CLASS rather than $PACKAGE I don't know.)
Ben
------------------------------
Date: Wed, 27 Jan 2010 21:36:58 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: permalink to latest devel release of perl?
Message-Id: <q8o637-qeu.ln1@osiris.mauzo.dyndns.org>
Quoth kj <no.email@please.post>:
>
> Is there some fixed URL that always points to the latest devel
> release of perl?
Do you mean devel release (that is, currently 5.11.4)? Are you aware
that these are not terribly stable, generally only slightly more so than
a git checkout?
Anyway, src/devel.tar.gz on any CPAN mirror.
> Also, is there some *fixed* string (i.e. invariant irrespective of
> the number of the latest perl version) that one could use as the
> argument of the get/make/test/install cpan shell commands, and that
> would download/build/test/install the latest devel release of perl?
I'm fairly sure installing perl using CPAN.pm is not recommended any
more. Apart from anything else, installing a dev release like this will
attempt to overwrite your system perl, which is a *very* bad idea.
Ben
------------------------------
Date: Wed, 27 Jan 2010 21:43:06 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: print array with separator?
Message-Id: <ako637-qeu.ln1@osiris.mauzo.dyndns.org>
Quoth Jürgen Exner <jurgenex@hotmail.com>:
> "C.DeRykus" <derykus@gmail.com> wrote:
> >I prefer the for modifier but wish 'void' was a keyword for side-
> >effects only map use.
Dear Lord no. That's as bad as the people who insist on casting
everything to (void) in C. Evaluating a function in void context is a
perfectly ordinary thing to do, so why does it need a redundant keyword?
> Doesn't
> undef = map .....
> work (I didn't try it)?
No, that's scalar assignment, which gives scalar context to the RHS. At
runtime you get 'Modification of a read-only value attempted', of
course.
Ben
------------------------------
Date: Wed, 27 Jan 2010 16:10:08 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: print array with separator?
Message-Id: <4152e2c8-249c-4d66-bb1b-09860950a431@a12g2000yqj.googlegroups.com>
On Jan 27, 1:43=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth J=FCrgen Exner <jurge...@hotmail.com>:
>
> > "C.DeRykus" <dery...@gmail.com> wrote:
> > >I prefer the for modifier but wish 'void' was a keyword for side-
> > >effects only map use.
>
> Dear Lord no. That's as bad as the people who insist on casting
> everything to (void) in C. Evaluating a function in void context is a
> perfectly ordinary thing to do, so why does it need a redundant keyword?
I mentioned "crazies" but you're probably right. Rather than
judicious use in cases like map to bridge changed semantics,
it'd turn viral.
>
> > Doesn't
> > =A0 =A0undef =3D map .....
> > work (I didn't try it)?
>
> No, that's scalar assignment, which gives scalar context to the RHS. At
> runtime you get 'Modification of a read-only value attempted', of
> course.
>
Ah. I suppose you could still signal map's only purpose were the
side-effects with '() =3D map ...' (added keystrokes+slower though)
--
Charles DeRykus
------------------------------
Date: Wed, 27 Jan 2010 16:41:29 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: print array with separator?
Message-Id: <8f3ef9e5-d738-4d00-8ff6-a3b5ce246db2@o28g2000yqh.googlegroups.com>
On Jan 27, 11:51=A0am, "Dr.Ruud" <rvtol+use...@xs4all.nl> wrote:
> Jochen Lehmeier wrote:
>> ...
>
> Yeah, though I'd rather see an error if an immutable is violated.
>
> But wait, it does:
>
> perl -e'grep ++$_, -2..2'
>
> perl -e'grep ++$_, -2,-1,0,1,2'
> Modification of a read-only value attempted at -e line 1.
>
> perl -e'grep ++$_, @{[ -2,-1,0,1,2 ]}'
>
> So -2..2 just iterates mutables.
>
That seems wrong (or at least surprising) because the range op
should just generate a list - in this case a list of literals -
not an array of mutables. That is, these two appear to be
equivalently processed by grep:
perl -e 'grep ++$_, -2..2'
perl -e 'grep ++$_, [-2..2]'
grep appears to be creating a temp array in the former case instead
of a list.
--
Charles DeRykus
------------------------------
Date: Wed, 27 Jan 2010 19:54:28 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: print array with separator?
Message-Id: <87sk9r3v7f.fsf@quad.sysarch.com>
>>>>> "CD" == C DeRykus <derykus@gmail.com> writes:
CD> perl -e 'grep ++$_, -2..2'
CD> perl -e 'grep ++$_, [-2..2]'
CD> grep appears to be creating a temp array in the former case instead
CD> of a list.
the second line makes no sense as it is passing an array ref to grep.
perl -le 'print grep ++$_, [-2..2]'
162189897
the ref address get numified and then gets bumped.
as for the other issues about modifying the ranges vs a list, possible
this is from the optimization that perl does with large ranges. it used
to generate them as a list and now it creates an iterator. another
thought is that to make a range list it needs to create real sv's so it
can bump them. but a list of ints is passed as constants and so they
can't be modified. this harkens back to a bug i found when 5.6 changed
qw() from a runtime split (which made sv's) to a compile time list of
constant strings. some code i was analyzing for porting to 5.6 was
crashing due to modification of constants in the qw. this feels like a
similar thing. a generated list has to be sv's which can be modified. a
passed list of constants are still constants and can't be modified.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 28 Jan 2010 01:18:00 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: print array with separator?
Message-Id: <875737-6dv.ln1@osiris.mauzo.dyndns.org>
Quoth "C.DeRykus" <derykus@gmail.com>:
> On Jan 27, 1:43 pm, Ben Morrow <b...@morrow.me.uk> wrote:
> > Quoth Jürgen Exner <jurge...@hotmail.com>:
> >
> > > "C.DeRykus" <dery...@gmail.com> wrote:
> > > >I prefer the for modifier but wish 'void' was a keyword for side-
> > > >effects only map use.
> >
> > Dear Lord no. That's as bad as the people who insist on casting
> > everything to (void) in C. Evaluating a function in void context is a
> > perfectly ordinary thing to do, so why does it need a redundant keyword?
>
> I mentioned "crazies" but you're probably right. Rather than
> judicious use in cases like map to bridge changed semantics,
> it'd turn viral.
There are no changed semantics, just an optimisation.
> > > Doesn't
> > > undef = map .....
> > > work (I didn't try it)?
> >
> > No, that's scalar assignment, which gives scalar context to the RHS. At
> > runtime you get 'Modification of a read-only value attempted', of
> > course.
> >
>
> Ah. I suppose you could still signal map's only purpose were the
> side-effects with '() = map ...' (added keystrokes+slower though)
That's a list assignment, so the RHS is in list context (it *is*
possible to try these things before posting, you know).
Ben
------------------------------
Date: Wed, 27 Jan 2010 21:46:25 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: When to use "use strict;"?
Message-Id: <hqo637-qeu.ln1@osiris.mauzo.dyndns.org>
Quoth "jl_post@hotmail.com" <jl_post@hotmail.com>:
>
> Notice that $data, $length, and $verbose are declared with "my", but
> $result is not. As a result, if you copy-and-paste this code into a
> program that has "use strict;" you'll probably see an error that
> $result was not declared.
Cut-and-paste (or rather, copy-and-paste) is *always* a mistake when
programming; even if its from examples. You should *read* the example,
*understand* it, and then write your own code using that understanding.
Ben
------------------------------
Date: Wed, 27 Jan 2010 16:53:54 -0600
From: John Bokma <john@castleamber.com>
Subject: Re: When to use "use strict;"?
Message-Id: <878wbj5fct.fsf@castleamber.com>
Ben Morrow <ben@morrow.me.uk> writes:
> Quoth "jl_post@hotmail.com" <jl_post@hotmail.com>:
>>
>> Notice that $data, $length, and $verbose are declared with "my", but
>> $result is not. As a result, if you copy-and-paste this code into a
>> program that has "use strict;" you'll probably see an error that
>> $result was not declared.
>
> Cut-and-paste (or rather, copy-and-paste) is *always* a mistake when
> programming; even if its from examples. You should *read* the example,
> *understand* it, and then write your own code using that
> understanding.
What an extremistic view point, sigh. I agree that you must understand
the example, but what if the example does *exactly* what you want,
shouldn't you just copy it or does one really have to type it over to be
a real programmer? Oh, my, I just copied an example today. Thankfully it
was Python, and not Perl.
--
John Bokma j3b
Hacking & Hiking in Mexico - http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 2793
***************************************