From: Vincent Pit Date: Tue, 10 Nov 2009 21:29:07 +0000 (+0100) Subject: Add EXISTS and DELETE methods to Env.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b5ebbd35aaa76c78e1c459037c7eae45954d508b;p=p5sagit%2Fp5-mst-13.2.git Add EXISTS and DELETE methods to Env.pm --- diff --git a/lib/Env.pm b/lib/Env.pm index eb9187f..deac5fc 100644 --- a/lib/Env.pm +++ b/lib/Env.pm @@ -1,6 +1,6 @@ package Env; -our $VERSION = '1.00'; +our $VERSION = '1.01'; =head1 NAME @@ -132,8 +132,7 @@ sub TIEARRAY { sub FETCHSIZE { my ($self) = @_; - my @temp = split($sep, $ENV{$$self}); - return scalar(@temp); + return 1 + scalar(() = $ENV{$$self} =~ /\Q$sep\E/g); } sub STORESIZE { @@ -161,6 +160,19 @@ sub STORE { return $value; } +sub EXISTS { + my ($self, $index) = @_; + return $index < $self->FETCHSIZE; +} + +sub DELETE { + my ($self, $index) = @_; + my @temp = split($sep, $ENV{$$self}); + my $value = splice(@temp, $index, 1, ()); + $ENV{$$self} = join($sep, @temp); + return $value; +} + sub PUSH { my $self = shift; my @temp = split($sep, $ENV{$$self}); @@ -232,4 +244,11 @@ sub FETCH { return $ENV{$$self . ';' . $index}; } +sub EXISTS { + my ($self, $index) = @_; + return $index < $self->FETCHSIZE; +} + +sub DELETE { } + 1;