If you compare the code I gave you and your modified script you will notice that you have lost a couple of very important characters, changing the dereference operator(->) to the subtraction operator (-), i.e.
my @posns = split m{}, $tests[ $idx ]-[ $subidx ]; $results[ $idx ]-[ $subidx ] ++
should be
my @posns = split m{}, $tests[ $idx ]->[ $subidx ]; $results[ $idx ]->[ $subidx ] ++
With regard to say, it was introduced with Perl 5.10 so use print if your version is earlier. If on 5.10, you have to put use 5.010 in your script to access newer features like say. I've not used Perl 5.12 yet so I'm not sure whether the use is necessary there.
You have changed the script to use files but I would recommend that you use the three-argument form of open, employ lexical filehandles and also check for success, giving the o/s error on failure. Instead of
open(INFILE1, $FILENAME1);
do
open my $input1FH, q{<}, $FILENAME1 or die qq{open: < $FILENAME1: $!\n};
I hope this helps you moveforward.
Cheers,
JohnGG
In reply to Re^5: Count similar characters in a row
by johngg
in thread Count similar characters in a row
by $new_guy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |