Re: [PATCH] perlfunc.pod grammar fixes
On Thu, 2005-07-28 at 00:37 -0700, Michael G Schwern wrote: > > Note that a block by itself is semantically identical to a loop > > -that executes once. Thus C can be used to effect an early > > +that executes once. Thus C can be used to affect an early > > exit out of such a block. > > effect is a noun. affect is a verb so I think this change is correct. It's also a transitive verb, so "to effect (some direct object)" is valid English, if potentially unclear. -- c
Re: [PATCH] XSLoader for Storable
On Sun, 2005-06-26 at 21:03 -0700, Michael G Schwern wrote: > Please observe the dire warning layed out in my sig below. > > DynaLoader is documented as needing to be inherited from. You screw with > that you flirt with breakage just to avoid writing one line of code. Most of its documentation suggests using a standard function call, not to mention the usage error seven lines in. If it really needs inheritance and a method call, it needs a documentation patch (and hopefully one that avoids the blepharitic indirect object syntax). -- c
Re: [PATCH] XSLoader for Storable
On Sun, 2005-06-26 at 18:35 -0700, Michael G Schwern wrote: > That doesn't seem right. It means Storable only inherits from DynaLoader > in the scope of that bootstrap call and I don't see why that's necessary. > It wasn't necessary before. > > "push @ISA, qw(DynaLoader)" is safer and equivalent to what was happening > before the patch. Even easier (especially on the eyes): DynaLoader::bootstrap( 'Storable', $VERSION ); -- c
Re: Carp vs Carp::Heavy was: Re: [PATCH] Put Carp into the Tarpit (No Carp #2 - Archive::Tar)
On Sun, 2005-06-26 at 15:16 +0200, Tels wrote: > So, in conclusion, I think it is worthwhile to apply these changes, > because: > > * no matter how you measure it, memory consumption goes down ... except for all of the duplicate subroutines in all of the patched modules. > * the changes are small and pure-perl only ... and duplicate code. I have serious doubts about the efficacy of copying and pasting code to reduce memory use. -- c
[PATCH pod/perlfunc.pod pod/perlobj.pod pod/perltooc.pod] Recommend Against UNIVERSAL:: Methods as Functions, take 2
Here's a variant of the previous patch with feedback incorporated. The only change is to the perlfunc patch, to make the possibilities and strengths and weaknesses of each approach more explicit. -- c --- pod/perlfunc.pod~ 2005-06-15 11:43:41.0 -0700 +++ pod/perlfunc.pod2005-06-15 11:46:27.0 -0700 @@ -1158,9 +1158,11 @@ is sometimes preferable to matching particular string values of $@ using regular expressions. Here's an example: +use Scalar::Util 'blessed'; + eval { ... ; die Some::Module::Exception->new( FOO => "bar" ) }; if ($@) { -if (ref($@) && UNIVERSAL::isa($@,"Some::Module::Exception")) { +if (blessed($@) && [EMAIL PROTECTED]>isa("Some::Module::Exception")) { # handle Some::Module::Exception } else { @@ -4195,9 +4197,6 @@ unless (ref($r)) { print "r is not a reference at all.\n"; } -if (UNIVERSAL::isa($r, "HASH")) { # for subclassing - print "r is a reference to something that isa hash.\n"; -} See also L. --- pod/perlobj.pod~2005-06-15 11:47:01.0 -0700 +++ pod/perlobj.pod 2005-06-15 11:50:34.0 -0700 @@ -373,18 +373,19 @@ C returns I if its object is blessed into a subclass of C -You can also call C as a subroutine with two arguments. -The first does not need to be an object or even a reference. This -allows you to check what a reference points to, or whether -something is a reference of a given type. Example +You can also call C as a subroutine with two arguments. Of +course, this will do the wrong thing if someone has overridden C in a +class, so don't do it. -if(UNIVERSAL::isa($ref, 'ARRAY')) { - #... -} +If you need to determine whether you've received a valid invocant, use the +C function from L: -To determine if a reference is a blessed object, you can write +if (blessed($ref) && $ref->isa( 'Some::Class')) { +# ... +} -print "It's an object\n" if UNIVERSAL::isa($val, 'UNIVERSAL'); +C returns the name of the package the argument has been +blessed into, or C. =item can(METHOD) @@ -392,21 +393,9 @@ if it does then a reference to the sub is returned, if it does not then I is returned. -C can also be called as a subroutine with two arguments. -It'll always return I if its first argument isn't an object or a -class name.So here's another way to check if a reference is a -blessed object - -print "It's still an object\n" if UNIVERSAL::can($val, 'can'); - -You can also use the C function of Scalar::Util: - -use Scalar::Util 'blessed'; - -my $blessing = blessed $suspected_object; - -C returns the name of the package the argument has been -blessed into, or C. +C can also be called as a subroutine with two arguments. It'll +always return I if its first argument isn't an object or a class name. +The same caveats for calling C directly apply here, too. =item VERSION( [NEED] ) --- pod/perltooc.pod~ 2005-06-15 11:51:14.0 -0700 +++ pod/perltooc.pod2005-06-15 11:52:08.0 -0700 @@ -1089,7 +1089,10 @@ if (my $coderef = $self->can($parent . "::CData1")) { $self->$coderef($newvalue); } -} +} + +If you override C in your own classes, be sure to return the +reference appropriately. =head2 Locking the Door and Throwing Away the Key
[PATCH pod/perlfunc.pod pod/perlobj.pod pod/perltooc.pod] Recommend Against NIVERSAL:: Methods as Functions
The attached patch rephrases three pieces of Perl documentation which suggest that calling UNIVERSAL::isa() or UNIVERSAL::can() directly is a good idea. The revised version explains why it's a bad idea and gives more correct recommendations. (It may be appropriate to add a short paragraph about using Scalar::Util::reftype() to the second chunk in perlfunc.pod; I'm happy to do this if so.) -- c --- pod/perlfunc.pod~ 2005-06-15 11:43:41.0 -0700 +++ pod/perlfunc.pod 2005-06-15 11:46:27.0 -0700 @@ -1158,9 +1158,11 @@ is sometimes preferable to matching particular string values of $@ using regular expressions. Here's an example: +use Scalar::Util 'blessed'; + eval { ... ; die Some::Module::Exception->new( FOO => "bar" ) }; if ($@) { -if (ref($@) && UNIVERSAL::isa($@,"Some::Module::Exception")) { +if (blessed($@) && [EMAIL PROTECTED]>isa("Some::Module::Exception")) { # handle Some::Module::Exception } else { @@ -4195,9 +4197,6 @@ unless (ref($r)) { print "r is not a reference at all.\n"; } -if (UNIVERSAL::isa($r, "HASH")) { # for subclassing - print "r is a reference to something that isa hash.\n"; -} See also L. --- pod/perlobj.pod~ 2005-06-15 11:47:01.0 -0700 +++ pod/perlobj.pod 2005-06-15 11:50:34.0 -0700 @@ -373,18 +373,19 @@ C returns I if its object is blessed into a subclass of C -You can also call C as a subroutine with two arguments. -The first does not need to be an object or even a reference. This -allows you to check what a reference points to, or whether -something is a reference of a given type. Example +You can also call C as a subroutine with two arguments. Of +course, this will do the wrong thing if someone has overridden C in a +class, so don't do it. -if(UNIVERSAL::isa($ref, 'ARRAY')) { - #... -} +If you need to determine whether you've received a valid invocant, use the +C function from L: -To determine if a reference is a blessed object, you can write +if (blessed($ref) && $ref->isa( 'Some::Class')) { +# ... +} -print "It's an object\n" if UNIVERSAL::isa($val, 'UNIVERSAL'); +C returns the name of the package the argument has been +blessed into, or C. =item can(METHOD) @@ -392,21 +393,9 @@ if it does then a reference to the sub is returned, if it does not then I is returned. -C can also be called as a subroutine with two arguments. -It'll always return I if its first argument isn't an object or a -class name.So here's another way to check if a reference is a -blessed object - -print "It's still an object\n" if UNIVERSAL::can($val, 'can'); - -You can also use the C function of Scalar::Util: - -use Scalar::Util 'blessed'; - -my $blessing = blessed $suspected_object; - -C returns the name of the package the argument has been -blessed into, or C. +C can also be called as a subroutine with two arguments. It'll +always return I if its first argument isn't an object or a class name. +The same caveats for calling C directly apply here, too. =item VERSION( [NEED] ) --- pod/perltooc.pod~ 2005-06-15 11:51:14.0 -0700 +++ pod/perltooc.pod 2005-06-15 11:52:08.0 -0700 @@ -1089,7 +1089,10 @@ if (my $coderef = $self->can($parent . "::CData1")) { $self->$coderef($newvalue); } -} +} + +If you override C in your own classes, be sure to return the +reference appropriately. =head2 Locking the Door and Throwing Away the Key
Re: [perl #35329] [PATCH] 5.9.2 constify
On Mon, 2005-05-09 at 09:47 +0100, Nicholas Clark wrote: > On Sun, May 08, 2005 at 01:10:31PM +0200, Andreas Mohr wrote: > > Will my ranting here get perl.com fixed already, or should I report it to > > that > > site directly? > > I'd suggest reporting it directly. I'm not aware if they read the > perl5-porters list. I do, but I don't see a significant benefit to changing Perl.com from listing *released versions* of Perl to explaining how to hack on Perl. However, I have no problem adding a couple of sentences to point to perlhack.pod for people who want to participate in the development of Perl. -- c
Re: 5.8.7 perldelta
On Tue, 2005-04-26 at 16:36 +0100, Nicholas Clark wrote: > For new projects the core perl team would strongly recommend that you use > dedicated, single purpose security tools such as C in preference to > C. Is there some doubt? "strongly recommends" is stronger and, I think, more accurate. -- c
Re: [PATCH] 5.6 File::Glob documentation insufficient for use
On Wed, 2005-03-30 at 03:41 +0200, Steven Schubiger wrote: > +The glob angel-bracket operator <> is a pathname generator that implements > the Angle, I believe. -- c
Re: [PATCH] to provide a Perl6-style 'say' keyword.
On Fri, 2005-03-11 at 17:58 +, Nigel Sandever wrote: > Perhaps it would be possible to consider some mechanism that would allow new > features without imposing them on those that didn't want them, or any > incompatibilities they might cause? That *is* the CPAN. -- c
Re: [perl #33173] shellwords.pl and tainting
On Tue, 2004-12-28 at 22:29 +0300, Alexey Tourbin wrote: > --- perl-5.9.2.23688/lib/Text/ParseWords/taint.t- 2004-12-28 21:21:26 > +0300 > +++ perl-5.9.2.23688/lib/Text/ParseWords/taint.t 2004-12-28 21:39:56 > +0300 > @@ -0,0 +1,23 @@ > +#!./perl -Tw > +# [perl #33173] shellwords.pl and tainting > + > +BEGIN { > +chdir 't' if -d 't'; > +@INC = '../lib'; > +require Config; > +if ($Config::Config{extensions} !~ /\bList\/Util\b/) { > + print "1..0 # Skip: Scalar::Util was not built\n"; > + exit 0; > +} > +} > + > +use Text::ParseWords qw(shellwords old_shellwords); > +use Scalar::Util qw(tainted); > + > +print "1..2\n"; > + > +print "not " if grep { not tainted($_) } shellwords("$0$^X"); > +print "ok 1\n"; > + > +print "not " if grep { not tainted($_) } old_shellwords("$0$^X"); > +print "ok 2\n"; This being a module, it's okay to use at least test.pl here, if not Test::More. It should have test comments either way. -- c
Re: License for the Cwd module
On Tue, 2004-11-30 at 22:26 -0500, Michael G Schwern wrote: > Ya know, the FSF folks do actually know a lot about this. If nothing else, > some of them ARE lawyers and can give us advice on what's a good idea and > what isn't. > One fellow at OSCON was fairly chomping at the bit wanting to help with > Perl's licensing and copyright issues. Shame I can't remember his name. > (It wasn't Brad Khun, who, incidentally, has mellowed). TPF is working on this with help from the FSF. It's under control and there should be something public in the next short while. E-mail allison at perl dot org if you want to help. In the meantime, hey, isn't that A UNICODE THREADING REGEX BUG -- ON VMS, triggered by a MakeMaker regression! -- c
Re: License for the Cwd module
On Mon, 2004-11-29 at 20:39 -0600, Ken Williams wrote: > I had the same question and I have no idea about the answer. I'm not > particularly interested in being the copyright owner, though. Maybe > the Perl Foundation? I've always wanted to make a more substantial > gift... ;-) TPF may be able to do this. I'll look into it. -- c
Re: Tests failing when core extensions not built
On Sun, 2004-10-31 at 08:28, Nicholas Clark wrote: > On Sun, Oct 31, 2004 at 01:24:34AM +0100, Nicholas Clark wrote: > > Would it be a good idea to use Config (or maybe just config.sh) to work > > out which extensions are not enabled, and skip corresponding tests in ext? > I committed change 23448 which does this. If it doesn't work well, we > can take it out. It's a reasonable approach in code and intent. As long as something somewhere warns about not building the unbuilt extensions, it should be fine. -- c
[PATCH perl.c pod/perl.pod pod/perlfaq2.pod] Rephrase "Perl Home Page" References
The (first) attached patch rephrases some documentation, including the output of 'perl -v' to refer to Perl.org as the Perl Home Page, with Perl.com marked more clearly as a separate entity. The second patch updates my e-mail address in AUTHORS from an old account. -- c --- perl.c~ 2004-10-19 21:59:49.0 -0700 +++ perl.c 2004-10-19 22:00:03.0 -0700 @@ -2810,7 +2810,7 @@ GNU General Public License, which may be found in the Perl 5 source kit.\n\n\ Complete documentation for Perl, including FAQ lists, should be found on\n\ this system using `man perl' or `perldoc perl'. If you have access to the\n\ -Internet, point your browser at http://www.perl.com/, the Perl Home Page.\n\n"); +Internet, point your browser at http://www.perl.org/, the Perl Home Page.\n\n"); my_exit(0); case 'w': if (! (PL_dowarn & G_WARN_ALL_MASK)) --- pod/perl.pod~ 2004-10-19 22:27:20.0 -0700 +++ pod/perl.pod 2004-10-19 22:37:00.0 -0700 @@ -373,9 +373,9 @@ a2p awk to perl translator s2p sed to perl translator - http://www.perl.com/ the Perl Home Page + http://www.perl.org/ the Perl Home Page + http://www.perl.com/ Perl articles (O'Reilly Media) http://www.cpan.org/ the Comprehensive Perl Archive - http://www.perl.org/ Perl Mongers (Perl user groups) =head1 DIAGNOSTICS --- pod/perlfaq2.pod~ 2004-10-19 22:27:13.0 -0700 +++ pod/perlfaq2.pod 2004-10-19 22:36:11.0 -0700 @@ -523,8 +523,8 @@ =head2 What is perl.com? Perl Mongers? pm.org? perl.org? cpan.org? -The Perl Home Page at http://www.perl.com/ is currently hosted by -The O'Reilly Network, a subsidiary of O'Reilly and Associates. +Perl.com at http://www.perl.com/ is part of the O'Reilly Network, a subsidiary +of O'Reilly Media. Perl Mongers is an advocacy organization for the Perl language which maintains the web site http://www.perl.org/ as a general advocacy --- AUTHORS~ 2004-10-19 22:15:35.0 -0700 +++ AUTHORS 2004-10-19 22:15:58.0 -0700 @@ -137,7 +137,7 @@ Christian Kirsch <[EMAIL PROTECTED]> Christopher Chan-Nui <[EMAIL PROTECTED]> Christopher Davis <[EMAIL PROTECTED]> -chromatic <[EMAIL PROTECTED]> +chromatic <[EMAIL PROTECTED]> Chuck D. Phillips <[EMAIL PROTECTED]> Chuck Phillips <[EMAIL PROTECTED]> Chunhui Teng <[EMAIL PROTECTED]>
Re: new [PATCH] require Carp; vs. use Carp; in warnings.pm
On Thu, 2004-09-30 at 06:54, Rafael Garcia-Suarez wrote: > Tels wrote: > > I would also like to patch the doc of Carp to promote the > > > > require Carp; > > Carp::croak ("..."); > > > > syntax over the use one. Should I send a patch for this? > > Why not -- once this issue is sorted out. Wasn't the point of Carp::Heavy to make this unnecessary? If that's the case, fixing Carp would be a lot easier than changing "use Carp;" to "require Carp;" everywhere. -- c
Re: [perl #18232] Encode::is_utf8 seems to have side effects
On Thursday 07 November 2002 09:08, Rafael Garcia-Suarez wrote: > chromatic <[EMAIL PROTECTED]> wrote: > > Test::More::ok() calls Test::Builder::ok(), which performs a > > substitution. I could patch it to localize all of the punctuation > > variables, but think better style might be to say "Don't rely on your > > captures persisting across function calls." > ??? $1 is automatically localized AFAIK. Er, yeah. It is, now that I tried a proper test. Sorry about the false fix -- I thought this was like an earlier bug/feature. It's apparently not. -- c
[PROPOSED PATCH lib/English.t] (was Re: Failures on Win95...)
On Mon, 25 Feb 2002 15:39:11 -0700, Nikola Knezevic wrote: > If someone wants extended reports, just yell. > *..\lib/English.t 1 256541 1.85% 48 Potential patch attached for this. I'm not thrilled with it, but it seems much more portable. > ..\lib/File/stat.t 1 256191 5.26% 18 > *..\lib/File/stat.t 1 256191 5.26% 18 Consider this a yell. -- c --- lib/File/stat.t~Thu Feb 21 13:52:32 2002 +++ lib/File/stat.t Thu Feb 21 14:10:49 2002 @@ -16,10 +16,10 @@ $hasst = 0 unless $Config{'i_sysstat'} eq 'define'; unless ($hasst) { plan skip_all => "no sys/stat.h"; exit 0 } our @stat = stat "TEST"; # This is the function stat. -unless (@stat) { print "1..0 # Skip: no file TEST\n"; exit 0 } +unless (@stat) { plan skip_all => "1..0 # Skip: no file TEST"; exit 0 } } -plan tests => 16; +plan tests => 19; use_ok( 'File::stat' ); @@ -55,6 +55,20 @@ is( $stat->blksize, $stat[11], "IO block size in position 11" ); is( $stat->blocks, $stat[12], "number of blocks in position 12" ); + +SKIP: { + local *STAT; + skip(2, "Could not open file: $!") unless open(STAT, 'TEST'); + ok( File::stat::stat('STAT'), '... should be able to find filehandle' ); + + package foo; + local *STAT = *main::STAT; + main::ok( my $stat2 = File::stat::stat('STAT'), + '... and filehandle in another package' ); + close STAT; + + main::is( "@$stat", "@$stat2", '... and must match normal stat' ); +} local $!; $stat = stat '/notafile'; --- lib/File/stat.pm~ Thu Feb 21 14:11:48 2002 +++ lib/File/stat.pmThu Feb 21 14:09:23 2002 @@ -53,7 +53,7 @@ local $!; no strict 'refs'; require Symbol; - $fh = \*{Symbol::qualify($arg)}; + $fh = \*{ Symbol::qualify( $arg, caller() )}; return unless defined fileno $fh; } return populate(CORE::stat $fh);
Re: [PATCH lib/Term/Cap.t] Robustify %ENV Handling in Test (was Re:
In article <[EMAIL PROTECTED]>, "Andy Dougherty" <[EMAIL PROTECTED]> wrote: > Ahh. Tricky. So the fact that my system passes the lib/Term/Cap.t test is no > guarantee that I can, in fact, use lib/Term/Cap.pm. Hmm. Interesting. I > mean, I see the point, but still, it's a bit odd. You're right. The test shouldn't be so portable that it runs where the module itself won't. (Term::Cap ought to run just fine on a Debian box, though.) Perhaps it should skip all tests without any of @ENV{qw(TERM TERMCAP TERMPATH)} set? Anyone possessing more experience with terminal emulation is welcome to jump in. -- c