This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Support Unicode properties Identifier_(Status|Type)
[perl5.git] / lib / Tie / Array.pm
index f4c6193..192983b 100644 (file)
@@ -1,9 +1,9 @@
 package Tie::Array;
 
-use 5.005_64;
+use 5.006_001;
 use strict;
 use Carp;
-our $VERSION = '1.01';
+our $VERSION = '1.07';
 
 # Pod documentation after __END__ below.
 
@@ -11,7 +11,6 @@ sub DESTROY { }
 sub EXTEND  { }
 sub UNSHIFT { scalar shift->SPLICE(0,0,@_) }
 sub SHIFT { shift->SPLICE(0,1) }
-#sub SHIFT   { (shift->SPLICE(0,1))[0] }
 sub CLEAR   { shift->STORESIZE(0) }
 
 sub PUSH
@@ -70,22 +69,21 @@ sub SPLICE {
     for (my $i=0; $i < @_; $i++) {
         $obj->STORE($off+$i,$_[$i]);
     }
-    return @result;
+    return wantarray ? @result : pop @result;
 }
 
 sub EXISTS {
     my $pkg = ref $_[0];
-    croak "$pkg dosn't define an EXISTS method";
+    croak "$pkg doesn't define an EXISTS method";
 }
 
 sub DELETE {
     my $pkg = ref $_[0];
-    croak "$pkg dosn't define a DELETE method";
+    croak "$pkg doesn't define a DELETE method";
 }
 
 package Tie::StdArray;
-use vars qw(@ISA);
-@ISA = 'Tie::Array';
+our @ISA = 'Tie::Array';
 
 sub TIEARRAY  { bless [], $_[0] }
 sub FETCHSIZE { scalar @{$_[0]} }
@@ -120,7 +118,7 @@ Tie::Array - base class for tied arrays
 
 =head1 SYNOPSIS
 
-    package NewArray;
+    package Tie::NewArray;
     use Tie::Array;
     @ISA = ('Tie::Array');
 
@@ -129,10 +127,10 @@ Tie::Array - base class for tied arrays
     sub FETCH { ... }
     sub FETCHSIZE { ... }
 
-    sub STORE { ... }        # mandatory if elements writeable
-    sub STORESIZE { ... }    # mandatory if elements can be added/deleted
-    sub EXISTS { ... }       # mandatory if exists() expected to work
-    sub DELETE { ... }       # mandatory if delete() expected to work
+    sub STORE { ... }       # mandatory if elements writeable
+    sub STORESIZE { ... }   # mandatory if elements can be added/deleted
+    sub EXISTS { ... }      # mandatory if exists() expected to work
+    sub DELETE { ... }      # mandatory if delete() expected to work
 
     # optional methods - for efficiency
     sub CLEAR { ... }
@@ -144,7 +142,7 @@ Tie::Array - base class for tied arrays
     sub EXTEND { ... }
     sub DESTROY { ... }
 
-    package NewStdArray;
+    package Tie::NewStdArray;
     use Tie::Array;
 
     @ISA = ('Tie::StdArray');
@@ -153,9 +151,9 @@ Tie::Array - base class for tied arrays
 
     package main;
 
-    $object = tie @somearray,Tie::NewArray;
-    $object = tie @somearray,Tie::StdArray;
-    $object = tie @somearray,Tie::NewStdArray;
+    $object = tie @somearray,'Tie::NewArray';
+    $object = tie @somearray,'Tie::StdArray';
+    $object = tie @somearray,'Tie::NewStdArray';
 
 
 
@@ -179,7 +177,7 @@ For developers wishing to write their own tied arrays, the required methods
 are briefly defined below. See the L<perltie> section for more detailed
 descriptive, as well as example code:
 
-=over
+=over 4
 
 =item TIEARRAY classname, LIST
 
@@ -278,9 +276,6 @@ There is no support at present for tied @ISA. There is a potential conflict
 between magic entries needed to notice setting of @ISA, and those needed to
 implement 'tie'.
 
-Very little consideration has been given to the behaviour of tied arrays
-when C<$[> is not default value of zero.
-
 =head1 AUTHOR
 
 Nick Ing-Simmons E<lt>nik@tiuk.ti.comE<gt>