Attribute-QueueStack

 view release on metacpan or  search on metacpan

lib/Tie/Array/Queue.pm  view on Meta::CPAN

	sub $_ { croak "$_ operation not permitted on queue" } 1
] || die $@ for qw(STORE POP UNSHIFT EXISTS DELETE SPLICE);

sub FETCH
{
	my $self = shift;
	
	# The first item on the stack can be peeked at.
	if ($_[0] == 0)
	{
		return $self->SUPER::FETCH(@_);
	}
	
	croak "FETCH operation not permitted on queue";
}

1;

__END__

=pod

lib/Tie/Array/Stack.pm  view on Meta::CPAN

	sub $_ { croak "$_ operation not permitted on stack" } 1
] || die $@ for qw(STORE SHIFT UNSHIFT EXISTS DELETE SPLICE);

sub FETCH
{
	my $self = shift;
	
	# The final item on the stack can be peeked at.
	if ($_[0] == -1 or $_[0] + 1 == scalar(@$self))
	{
		return $self->SUPER::FETCH(@_);
	}
	
	croak "FETCH operation not permitted on stack";
}

1;


__END__



( run in 0.368 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )