package N0i::Xchat::Scramble; use strict; use warnings; use base qw(N0i::Xchat::Base); sub version { return '0.1.0' } sub new { my ($class, %o) = @_; bless { %o }, $class; } sub scramble { my ($self, $text) = @_; return (undef, 'no text?!') unless defined $text && $text =~ /\S/; # don't fuck the nickname my $ret = ''; $text =~ s/^(\S+?:\s)\s*// and $ret .= $1; $text =~ s{\B(\w+)\B}{ join q{}, (split q{} , $1)[ sub { ($b, @*) = @_; $b = $*[$b] = pop while @_; @* }->( sort {rand~0} 0 .. -1 + length $1) ] }gex; return ($ret . $text, undef); } 1;