in reply to Re: Matching words based on letter content
in thread Matching words based on letter content
it will print@_ = qw (opt pot top stoop stop pit ipt);
Update: you´re right, i misread that. But this does it:opst counted 1 times oopst counted 1 times opt counted 3 times ipt counted 2 times
prints:use strict; my %h; @_ = qw (opt pot top stoop stop pit ipt); for ( @_ ) { my $last; $h{join "", grep { if ( $_ eq $last ) { "" } else { $last = $_; $_ } } sort split "", $_}++; } for ( keys %h ) { print "$_ counted $h{$_} times\n"; }
opst counted 2 times opt counted 3 times ipt counted 2 times
|
|---|