in reply to Re^4: Converting Filehandle to Array call in Object Creation
in thread Converting Filehandle to Array call in Object Creation

Patch: use the last element of the array for a counter.
sub TIEHANDLE($;$) { my $pkg = shift; my $ref = shift || []; push @{$ref}, 0; bless( $ref, $pkg ); } sub READLINE { my $ref = shift; return @{$ref} > 1 ? ">Seq" . ++$ref->[-1] . "\n" . shift (@{$ref} +) . "\n" : undef; }
so
use Tie::Handle::FromArray; my $fh = new Tie::Handle::FromArray ( ["AAAAAAAAAAAAAAA", "AAAAAAAGGAA +ACCA"] ); while (<$fh>) { print; }
prints
>Seq1 AAAAAAAAAAAAAAA >Seq2 AAAAAAAGGAAACCA


holli, /regexed monk/