lexical warnings update for docs and tests (from Paul Marquess)
[p5sagit/p5-mst-13.2.git] / lib / fields.pm
index 734cc0d..ac45810 100644 (file)
@@ -57,7 +57,7 @@ class fields using this pragma, then the operation is turned into an
 array access at compile time.
 
 The related C<base> pragma will combine fields from base classes and any
-fields declared using the C<fields> pragma.  This enables fields
+fields declared using the C<fields> pragma.  This enables field
 inheritance to work properly.
 
 Field names that start with an underscore character are made private to
@@ -85,9 +85,9 @@ This makes it possible to write a constructor like this:
 
     sub new {
        my Critter::Sounds $self = shift;
-       $self = fields::new($class) unless ref $self;
+       $self = fields::new($self) unless ref $self;
        $self->{cat} = 'meow';                          # scalar element
-       @$self->{'dog','bird'} = ('bark','tweet');      # slice
+       @$self{'dog','bird'} = ('bark','tweet');        # slice
        return $self;
     }
 
@@ -130,6 +130,7 @@ L<perlref/Pseudo-hashes: Using an array as a hash>
 use 5.005_64;
 use strict;
 no strict 'refs';
+use warnings::register;
 our(%attr, $VERSION);
 
 $VERSION = "1.01";
@@ -171,7 +172,8 @@ sub import {
        if ($fno and $fno != $next) {
            require Carp;
             if ($fno < $fattr->[0]) {
-                Carp::carp("Hides field '$f' in base class") if $^W;
+                warnings::warn("Hides field '$f' in base class") 
+                   if warnings::enabled();
             } else {
                 Carp::croak("Field name '$f' already in use");
             }