#! perl -slw use strict; package Chipper; my %pos; sub TIESCALAR { my( $class, $string ) = @_; my $self = bless \$string, $class; $pos{ $self } = 0; return $self; } sub FETCH { my( $self ) = @_; return $$_[ 0 ]; } sub STORE { my( $self, $value ) = @_; $pos{ $self } = 0; return $$self = $value; } sub chip { my( $self ) = @_; $pos{ $self } = 0, return undef if $pos{ $self } >= length $$self; return substr $$self, $pos{ $self }++, 1; } 1; package main; my $inst1 = tie my $str1, 'Chipper', 'The quick brown fox jumps over the lazy dog'; my $inst2 = tie my $str2, 'Chipper', 'Now is the time for all good men to come to the aid of the party'; print "($a$b)" while $a = $inst1->chip and $b = $inst2->chip;