use builtin qw(wanted_subroutines);
builtin contains a selection of subroutines that people have expressed would be
nice to have in the perl core, but the usage would not really be high
enough to warrant the use of a keyword, and the size so small such that
being individual extensions would be wasteful.
By default builtin does not export any subroutines. The subroutines defined are
undef is returned.
$! variable. The value of this new variable will be the numerical value of
NUMERIC in a numeric context and the string value of STRING in a string
context.
$foo = dualvar 10, "Hello";
$num = $foo + 2; # 12
$str = $foo . " world"; # Hello world
undef is returned.
$foo = max 1..10 # 10
$foo = max 3,9,12 # 12
$foo = max @bar, @baz # whatever
This function could be implemented using reduce like this
$foo = reduce { $_[0] > $_[1] ? $_[0] : $_[1] } 1..10
gt operator. If the list is empty then undef is returned. $foo = maxstr 'A'..'Z' # 'Z' $foo =
maxstr ``hello'',``world'' # ``world'' $foo = maxstr @bar,
@baz # whatever
This function could be implemented using reduce like this
$foo = reduce { $_[0] gt $_[1] ? $_[0] : $_[1] } 'A'..'Z'
undef is returned.
$foo = min 1..10 # 1
$foo = min 3,9,12 # 3
$foo = min @bar, @baz # whatever
This function could be implemented using reduce like this
$foo = reduce { $_[0] < $_[1] ? $_[0] : $_[1] } 1..10
lt operator. If the list is empty then undef is returned.
$foo = maxstr 'A'..'Z' # 'A'
$foo = maxstr "hello","world" # "hello"
$foo = maxstr @bar, @baz # whatever
This function could be implemented using reduce like this
$foo = reduce { $_[0] lt $_[1] ? $_[0] : $_[1] } 'A'..'Z'
Returns the result of the last call to BLOCK. If LIST is empty then
undef is returned. If LIST only contains one element then that element is
returned and BLOCK is not executed.
$foo = reduce { $_[0] < $_[1] ? $_[0] : $_[1] } 1..10 # min
$foo = reduce { $_[0] lt $_[1] ? $_[0] : $_[1] } 'aa'..'zz' # minstr
$foo = reduce { $_[0] + $_[1] } 1 .. 10 # sum
$foo = reduce { $_[0] . $_[1] } @bar # concat
$foo = sum 1..10 # 55
$foo = sum 3,9,12 # 24
$foo = sum @bar, @baz # whatever
This function could be implemented using reduce like this
$foo = reduce { $_[0] + $_[1] } 1..10
time function, see perlfunc.
builtin are
The sub is of general use and cannot be implemented in perl.
or
The sub is very commonly used and needs fast implementation in C.