Anagram-Groups
view release on metacpan or search on metacpan
lib/Anagram/Groups.pm view on Meta::CPAN
package Anagram::Groups;
use 5.006;
use warnings FATAL => 'all';
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw / anagram_groups /;
=head1 NAME
Anagram::Groups - The great new Anagram::Groups which will show us all the anagrams for the given array of strings!
=head1 VERSION
Version 0.02
=cut
our $VERSION = '0.02';
=head1 SYNOPSIS
use Anagram::Groups;
use Data::Dumper;
my $array_ref = ["reap", "pear", "listen", "silent"];
my $anagram_groups = anagram_group($array_ref);
print Dumper($anagram_groups);
...
=head1 EXPORT
A list of functions that can be exported. You can delete this section
if you don't export anything, such as for a purely object-oriented module.
=head1 SUBROUTINES/METHODS
=head2 anagram_groups
=cut
sub anagram_groups {
my ($array) = @_;
my $anagram_hashref = {};
for(@$array){
my $word = $_;
s/\s+//g;
push @{ $anagram_hashref->{ join '', sort split( //, $_ ) } }, $word;
}
return map {$anagram_hashref->{$_}} keys %$anagram_hashref;
}
=head1 AUTHOR
isunix, C<< <isunix1989 at gmail.com> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-anagram-groups at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Anagram-Groups>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Anagram::Groups
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Anagram-Groups>
=item * AnnoCPAN: Annotated CPAN documentation
L<http://annocpan.org/dist/Anagram-Groups>
( run in 3.029 seconds using v1.01-cache-2.11-cpan-f56aa216473 )