develooper Front page | perl.perl5.porters | Postings from October 2005 doc typo?

Thread Next
Jeff 'japhy' Pinyan
October 28, 2005 09:59
Subject: doc typo?
Message ID:
Quoth the POD:


This method receives a single argument, which is a reference to the 
variable or subroutine for which package-defined attributes are desired. 
The expected return value is a list of associated attributes. This list 
may be empty."

Um, is that so?

   use strict;
   use warnings;
   use attributes ();

     package Tie::StopWatch;

     sub TIESCALAR { my $class = shift; bless \time, $class }
     sub FETCH { my $self = shift; time - $$self; }
     sub STORE { my $self = shift; $$self = @_ ? shift : time }

     my %attr;

       print "FETCH: <@_>\n";
       my ($pkg, $var) = @_;
       return keys %{ $attr{$var} };

       my $pkg = shift;
       my $var = shift;
       my @bad;

       for (@_) {
         if ($_ eq 'Timer') {
           $attr{ tie $$var, 'Tie::StopWatch' }{$_} = 1;
         else {
           push @bad, $_;

       return @bad;

   my Tie::StopWatch $x :Timer;
   print "tied \$x: <@{[ attributes::get(tied $x) ]}>\n";

Running this yields:

   FETCH: <Tie::StopWatch Tie::StopWatch=SCALAR(0x8198924)>
   tied $x: <Timer>

Unless the POD has been corrected already (pending 5.8.8), this needs a 
patch.  Now, looking at the code, I see:

     my $stash = _guess_stash $svref;
     $stash = caller unless defined $stash;
     my $pkgmeth;
     $pkgmeth = UNIVERSAL::can($stash, "FETCH_${svtype}_ATTRIBUTES")
         if defined $stash && $stash ne '';
     return $pkgmeth ?
                 (_fetch_attrs($svref), $pkgmeth->($stash, $svref)) :

So $stash is the package that the reference resides in, right?  Once this 
has been confirmed for me, I can produce a doc patch.

Jeff "japhy" Pinyan        %  How can we ever be the sold short or
RPI Acacia Brother #734    %  the cheated, we who for every service  %  have long ago been overpaid?   %    -- Meister Eckhart

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About