in reply to acessing the contents of a file character by character

my $i = 0; $i++ while $stl =~ /$key1/g;

See perldoc perlre for the /g flag. And in general if you're trying to access a string character-by-character you're not thinking Perl, you're thinking C (or the like).

--
We're looking for people in ATL