in reply to Re^2: Using grep in a scalar context
in thread Using grep in a scalar context
Note: /AA/ matches the capital letter A followed by the capital letter A. It does not stand for "anything" in regular expressions.use Data::Dumper; my $string = 'MHDLKNDHASDRWT'; my %count_string; $count_string{$_}++ for $string =~ /(?=(..))/g; # Uses look-ahead to o +nly progress by one character. my @array = split //, $string; my %count_array; $count_array{ join q(), @array[$_, $_ + 1] }++ for 0 .. $#array - 1; print Dumper \%count_string, \%count_array;
Updated: Added the hashes.
|
|---|