My 3rd CPAN module Today: Sphinx::Control
Sphinx::Control controls Sphinx searchd.
Thanks.
Labels: Moose
Perl is not the whole part of life. I know!
Labels: Moose
Labels: CPAN
around 'shuffled_list' => sub {
my $next = shift;
my $ret = $next->(@_);
$ret = [ shuffle( @$ret ) ];
return $ret;
};1, 10, 6, 4, 2, 7, 9, 8, 3, 5Here we use 'around' instead of 'before' or 'after' because 'before' doesn't work according to this FAQ: http://search.cpan.org/~drolsky/Moose-0.57/lib/Moose/Cookbook/FAQ.pod#How_can_I_affect_the_values_in_@__using_before?
3, 4, 7, 2, 1, 9, 5, 6, 8, 10
Labels: Moose
Labels: git
Labels: Foorum
Labels: Moose, TheSchwartz
has 'scoreboard' => (
is => 'rw',
isa => 'Str',
trigger => sub {
my ($self, $dir) = @_;
return unless $dir;
# no endless loop when it's a file
if ($dir =~ /\/theschwartz\/scoreboard\./is) {
# get the real dir from $dir regardless a file
my (undef, $dir) = File::Spec->splitpath( $dir );
unless (-e $dir) {
mkdir($dir, 0755) or die "Can't create scoreboard directory '$dir': $!";
}
return;
}
# They want the scoreboard but don't care where it goes
if (($dir eq '1') or ($dir eq 'on')) {
$dir = File::Spec->tmpdir();
}
$dir .= '/theschwartz';
unless (-e $dir) {
mkdir($dir, 0755) or die "Can't create scoreboard directory '$dir': $!";
}
$self->{scoreboard} = $dir."/scoreboard.$$";
}
);now I have all I want.Labels: Moose
->verbose(1);
->verbose(0);
->verbose( sub {
my $msg = shift;
$msg =~ s/\s+$//;
print STDERR "[CUS] $msg\n";
} );
# then call ->debug depends on ->verbose.Labels: Moose