Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
package Queue; use warnings; use strict; sub TIESCALAR { my $class = shift; my @data = split ' ', $_[0]; bless( \@data, $class ); return \@data; } sub STORE { my $obj = shift; my $data = shift; push @$obj, $data; } sub FETCH { my $obj = shift; return shift( @$obj ); } return 1;
use warnings; use strict; use Queue; my $line; tie( $line, 'Queue', 'a b c d' ); print $line, "\n"; print $line, "\n"; print $line, "\n";
C:\Perl\bin>perl myqueue.pl a b c C:\Perl\bin>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with the tie function.
by chunlou (Curate) on Jul 27, 2003 at 09:38 UTC | |
|
Re: Help with the tie function.
by edan (Curate) on Jul 27, 2003 at 09:27 UTC |