use strict; my @buffer=( { data=>'', next=>1 },{ data=>'', next=>2, },{ data=>'', next=>3 }, { data=>'', next=>4 } ); sub store { if($buffer[$tail]{next} !=$head){ $buffer[$tail]{data}=shift; $tail=$buffer[$tail]{next}; return 1 }else{ return "Buffer is full"; } } sub retrieve{ if($tail != $head){ my $data=$buffer[$head]{data}; $head=$buffer[$head]{next}; return $data; }else{ return "Empty\n"; } } store "20"; print retrieve;