Common::Routine - Provide and synthesize very commonly used routines that are not provided in perl's build-in routines.
version 0.0.5
use Common::Routine ":all"; # routines used for math caculation my @array = 1..10; my $max = max @array # return 10 my $min = min @array # return 1 my $mean = mean @array # return 5.5 my $median = median @array # return 5.5 my $sum = sum @array # return 55 my $var = var @array # return 9.166667 my $sd = sd @array # return 3.02765 # routines for processing of string my $str = " abc "; my $t = trim $str; # return "abc" my $l = ltrim $str; # return "abc " my $r = rtrim $str; # return " abc" # format number my $num = 1234.3567; my $re = round $num; # return 1234 my $re = round $num, 2; # return 1234.36 my $re = ceil $num; # return 1235 my $re = floor $num; # return 1234 my $re = format_number $num # return 1,234.36 my $re = format_number $num,1 # return 1,234.4
The aim of this module is to provide the very common used functions that are not existed in perl's build-in functions
In my daily work, I will used some very common function that are very simple and useful, but I have to write it by myself or find and utilize them from different module. It's really boring to do this, and the purpose of this module is to combat this problem.
Rounds the number to the specified precision. if $precision is omitted, it will be setted 0 (default:0).
$precision
0
Return the entry in the list with the highest numerical value. If the list is empty then undef is returned. Arguments can be a Array or ArrayRef
undef
Similar to "max" but returns the entry in the list with the lowest numberical value. If the list is empty then undef is returned. Arguments can be a Array or ArrayRef
Returns the numerical sum of all the elements in @elements. If @elements is empty then undef is returned. Arguments can be a Array or ArrayRef
@elements
Returns the numerical mean of all the elements in @elements. If @elements is empty then undef is returned. Arguments can be a Array or ArrayRef
Returns the variance of list @elements If @elements is empty then undef is returned. Arguments can be a Array or ArrayRef
Returns the standard deviation of list @elements If @elements is empty then undef is returned. Arguments can be a Array or ArrayRef
Remove the whitespaces at the beginning or end of $string if $string is undef, then undef is returned
$string
Remove the whitespaces at the beginning of $string if $string is undef, then undef is returned
Remove the whitespaces at the end of $string if $string is undef, then undef is returned
Yan Xueqing <yanxueqing621@163.com>
This software is copyright (c) 2016 by Yan Xueqing.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Common::Routine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Common::Routine
CPAN shell
perl -MCPAN -e shell install Common::Routine
For more information on module installation, please visit the detailed CPAN module installation guide.