my @strings = ($genome1, $genome2); #### #! perl -sw use strict; # ... your existing code.... my @strings = \($genome1, $genome2); my ($total, $p) = (0, 0); do { $total = 0; #NOTE: Extra $'s v ........................................v print substr( $$strings[$_]}, $p, 60 ) . "\n" for 0 .. $#$strings; print "\n"; $p+=60; $total += length($_) - $p for @$strings; # And here! } while( $total > 0 ); __END__