You've already forked explain.depesz.com
mirror of
https://gitlab.com/depesz/explain.depesz.com.git
synced 2025-07-05 00:58:52 +02:00
23 lines
433 B
Perl
23 lines
433 B
Perl
![]() |
package Explain::Plugin::NumberFormat;
|
||
|
|
||
|
use Mojo::Base 'Mojolicious::Plugin';
|
||
|
|
||
|
sub register {
|
||
|
my ( $self, $app ) = @_;
|
||
|
|
||
|
# register helper
|
||
|
$app->helper(
|
||
|
commify_numbers => sub {
|
||
|
my $self = shift;
|
||
|
|
||
|
# Code taken from perlfaq5
|
||
|
local $_ = shift;
|
||
|
return $_ unless defined $_;
|
||
|
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
|
||
|
return $_;
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
1;
|