# TEST CODE ONLY BELOW HERE my $fifo1 = uFIFO(); # create a fifo - we can have as many as we need # create some test data and shuffle it my @test = ('a' .. 'z', 'i' .. 'r'); ($a=$_+rand @test-$_) and @test[$_,$a] = @test[$a,$_] for (0..$#test); printf "%15.15s: %s\n", 'Initial data', "@test"; # data in original order for comparison later #add some test data 26 stored from 36 passed print sprintf( '%15.15s: ', 'How many'), $fifo1->{add}( @test ),$/; print sprintf( '%15.15s: ', 'How many'), $fifo1->{add}( 'W' ),$/; # add a single value print sprintf( '%15.15s: ', 'How many'), $fifo1->{add}( qw( X Y Z ) ),$/; # add a list print sprintf( '%15.15s: ', 'How many'), $fifo1->{add}(),$/; #Add nothing? # add some 'somethings' interspersed with some 'nothings' # and return how many were added: should be 3 ('A', 0, '') ; undef aren't stored and 0 =~ "0" print sprintf( '%15.15s: ', 'How many added'),$fifo1->{add}( undef, chr(65), undef, 0, "", "0" ), $/; # Show only one copy of each made it in print sprintf( '%15.15s: ', 'Count & show'), 0+$fifo1->{all}(), ' : ', "@{[$fifo1->{all}()]}", $/; # process the list, randomly adding some more and printing them out as we process my $i; printf '%15.15s: ', 'Processed'; my $iterator = $fifo1->{iterator}(); while( my $temp = $iterator->{next}() ) { print $temp, ' ' ; (0 == int(rand 4)) and $fifo1->{add}( ++$i ); # Randomly add new values } print $/; print sprintf( '%15.15s: ', 'Ordered'), "@{ [ $fifo1->{ordered}() ] }", $/; print sprintf( '%15.15s: ', 'Unordered'), "@{ [ $fifo1->{all}() ] }" , $/; __END__ # Output from testing C:\test>uFIFO Initial data: l f s p l q r p q j m h j d r m n u n v i e o o x a c y z t g w b k i k How many: 26 How many: 1 How many: 3 How many: 0 How many added: 3 Count & show: 33 : A W X Y Z a b c d e f g h i j k l m n 0 o p q r s t u v w x y z Processed: l f s p q r j m h d n u v i e o x a c y z t g w b k W X Y Z A Ordered: l f s p q r j m h d n u v i e o x a c y z t g w b k W X Y Z A 0 1 2 3 4 5 6 7 8 9 Unordered: A W X Y Z a b c d e f g h i j k l m n 0 1 o 2 p 3 q 4 r 5 s 6 t 7 u 8 v 9 w x y z