NAME
Fauxtobox  fake autoboxing (call methods on plain scalars)
SYNOPSIS
use Fauxtobox;
my $n = "zomg">$_length; # $n = 4
print $n>$_sqrt; # "2"
# ... and many methods more
DESCRIPTION
This module provides fake autoboxing support. Autoboxing means being able to call methods on nonobjects like 42
or 'hello'
because the language will automatically wrap them in objects. If you want that, see autobox.
What this module does is much simpler: It exports a bunch of variables that can be used like methods. These method variables can be used on any value, not just objects.
Exported symbols
By default everything listed below is exported. If you don't want that, you can explicitly list the variables you want:
use Fauxtobox qw($_defined $_length $_apply);
For convenience you can omit the leading $_
in the import list:
use Fauxtobox qw(defined length apply);
Methods
If you call any of these fake methods on a real object, it will simply forward to a method of the same name, i.e. $obj>$_foo(...)
is equivalent to $obj>foo(...)
if $obj
is blessed.
Several functions in Perl take or return lists. In general, the method equivalents of these take and return array references instead, to make method chaining possible. Exceptions are noted below.
 $_apply

$X>$_apply($F)
is equivalent to$F>($X)
, so e.g."abc">$_apply(\&display)
is equivalent todisplay("abc")
.  $_list

$X>$_list
returns%{$X}
if$X
is a hash reference and@{$X}
otherwise. This is useful if you have an array reference and want to turn it into a list of its values.  $_qr

$X>$_qr
is equivalent toqr/$X/
.$X>$_qr($FLAGS)
is equivalent toqr/$X/$FLAGS
except that's a syntax error, but e.g.'^hello\s+world'>$_qr('i')
is equivalent toqr/^hello\s+world/i
.See "qr" in perlfunc.
 $_m

$X>$_m($REGEX)
is equivalent to$X =~ m/$REGEX/
.See "m" in perlfunc.
 $_m_g

$X>$_m_g($REGEX)
is equivalent to$X =~ m/$REGEX/g
.See "m" in perlfunc.
 $_m_gc

$X>$_m_gc($REGEX)
is equivalent to$X =~ m/$REGEX/gc
.See "m" in perlfunc.
 $_s

$X>$_s($REGEX, $REPLACEMENT)
is equivalent to$X =~ s/$REGEX/$REPLACEMENT>()/e
if$REPLACEMENT
is a subroutine reference and$X =~ s/$REGEX/$REPLACEMENT/
otherwise.See "s" in perlfunc.
 $_s_g

$X>$_s_g($REGEX, $REPLACEMENT)
is equivalent to$X =~ s/$REGEX/$REPLACEMENT>()/ge
if$REPLACEMENT
is a subroutine reference and$X =~ s/$REGEX/$REPLACEMENT/g
otherwise.See "s" in perlfunc.
 $_s_r

$X>$_s_r($REGEX, $REPLACEMENT)
is equivalent to$X =~ s/$REGEX/$REPLACEMENT>()/re
if$REPLACEMENT
is a subroutine reference and$X =~ s/$REGEX/$REPLACEMENT/r
otherwise.See "s" in perlfunc.
 $_s_gr

$X>$_s($REGEX, $REPLACEMENT)
is equivalent to$X =~ s/$REGEX/$REPLACEMENT>()/gre
if$REPLACEMENT
is a subroutine reference and$X =~ s/$REGEX/$REPLACEMENT/gr
otherwise.See "s" in perlfunc.
 $_test_r
 $_test_w
 $_test_x
 $_test_o
 $_test_R
 $_test_W
 $_test_X
 $_test_O
 $_test_e
 $_test_z
 $_test_s
 $_test_f
 $_test_d
 $_test_l
 $_test_p
 $_test_S
 $_test_b
 $_test_c
 $_test_t
 $_test_u
 $_test_g
 $_test_k
 $_test_T
 $_test_B
 $_test_M
 $_test_A
 $_test_C

These are file test operators.
$X>$_test_X
is equivalent toX $X
for all letters X listed above.See "X" in perlfunc.
 $_abs

$X>$_abs
is equivalent toabs $X
.See "abs" in perlfunc.
 $_alarm

$X>$_alarm
is equivalent toalarm $X
.See "alarm" in perlfunc.
 $_atan2

$X>atan2($Y)
is equivalent toatan2 $X, $Y
.See "atan2" in perlfunc.
 $_bless

$X>$_bless($CLASS)
is equivalent tobless $X, $CLASS
.$X>$_bless
is equivalent tobless $X
.See "bless" in perlfunc.
 $_chdir

$X>$_chdir
is equivalent tochdir $X
.See "chdir" in perlfunc.
 $_chmod

$X>$_chmod($MODE)
is equivalent tochmod $MODE, @{$X}
if$X
is an array reference andchmod $MODE, $X
otherwise.See "chmod" in perlfunc.
 $_chomp

$X>$_chomp
is equivalent tochomp @{$X}
if$X
is an array reference andchomp $X
otherwise.See "chomp" in perlfunc.
 $_chop

$X>$_chop
is equivalent tochop @{$X}
if$X
is an array reference andchop $X
otherwise.See "chop" in perlfunc.
 $_chown

$X>$_chown($UID, $GID)
is equivalent tochown $UID, $GID, @{$X}
if$X
is an array reference andchown $UID, $GID, $X
otherwise.See "chown" in perlfunc.
 $_chr

$X>$_chr
is equivalent tochr $X
.See "chr" in perlfunc.
 $_chroot

$X>$_chroot
is equivalent tochroot $X
.See "chroot" in perlfunc.
 $_cos

$X>$_cos
is equivalent tocos $X
.See "cos" in perlfunc.
 $_crypt

$X>$_crypt($SALT)
is equivalent tocrypt $X, $SALT
.See "crypt" in perlfunc.
 $_defined

$X>$_defined
is equivalent todefined $X
.  $_delete

$X>$_delete($KEY)
is equivalent todelete $X>[$KEY]
if $X is an array reference anddelete $X>{$KEY}
otherwise.See "delete" in perlfunc.
 $_die

$X>$_die
is equivalent todie $X
.See "die" in perlfunc.
 $_each

$X>$_each
is equivalent toeach @{$X}
if$X
is an array reference andeach %{$X}
otherwise.See "each" in perlfunc.
 $_eval

$X>$_eval
is equivalent toeval $X
.See "eval" in perlfunc.
 $_exec

$X>$_exec(@ARGS)
is equivalent toexec { $X } @ARGS
.$X>$_exec
is equivalent toexec @{$X}
if$X
is an array reference andexec $X
otherwise.See "exec" in perlfunc.
 $_exists

$X>$_exists($KEY)
is equivalent toexists $X>[$KEY]
if$X
is an array reference andexists $X>{$KEY}
otherwise.See "exists" in perlfunc.
 $_exit

$X>$_exit
is equivalent toexit $X
.See "exit" in perlfunc.
 $_exp

$X>$_exp
is equivalent toexp $X
.See "exp" in perlfunc.
 $_fc

$X>$_fc
is equivalent tofc $X
.See "fc" in perlfunc.
 $_getpgrp

$X>$_getpgrp
is equivalent togetpgrp $X
.  $_getpwnam

$X>$_getpwnam
is equivalent togetpwnam $X
.  $_getgrnam

$X>$_getgrnam
is equivalent togetgrnam $X
.  $_gethostbyname

$X>$_gethostbyname
is equivalent togethostbyname $X
.  $_getnetbyname

$X>$_getnetbyname
is equivalent togetnetbyname $X
.  $_getprotobyname

$X>$_getprotobyname
is equivalent togetprotobyname $X
.  $_getpwuid

$X>$_getpwuid
is equivalent togetpwuid $X
.  $_getgrgid

$X>$_getgrgid
is equivalent togetgrgid $X
.  $_getservbyname

$X>$_getservbyname($Y)
is equivalent togetservbyname $X, $Y
.  $_gethostbyaddr

$X>$_gethostbyaddr($Y)
is equivalent togethostbyaddr $X, $Y
.  $_getnetbyaddr

$X>$_getnetbyaddr($Y)
is equivalent togetnetbyaddr $X, $Y
.  $_getprotobynumber

$X>$_getprotobynumber
is equivalent togetprotobynumber $X
.  $_getservbyport

$X>$_getservbyport($Y)
is equivalent togetservbyport $X, $Y
.  $_glob

$X>$_glob
is equivalent to[ glob $X ]
, i.e. it returns an array reference of results.See "glob" in perlfunc.
 $_gmtime

$X>$_gmtime
is equivalent togmtime $X
.See "gmtime" in perlfunc.
 $_grep

$X>$_grep($F)
is equivalent to[ grep $F>($_), @{$X} ]
, i.e. it takes and returns an array reference. The function$F
is passed the current element as an argument.See "grep" in perlfunc.
 $_hex

$X>$_hex
is equivalent tohex $X
.See "hex" in perlfunc.
 $_index

$X>$_index($NEEDLE)
is equivalent toindex $X, $NEEDLE
.$X>$_index($NEEDLE, $OFFSET)
is equivalent toindex $X, $NEEDLE, $OFFSET
.See "index" in perlfunc.
 $_int

$X>$_int
is equivalent toint $X
.See "int" in perlfunc.
 $_join

$X>$_join($SEP)
is equivalent tojoin $SEP, @{$X}
.See "join" in perlfunc.
 $_keys

$X>$_keys
is equivalent to[ keys @{$X} ]
if$X
is an array reference and[ keys %{$X} ]
otherwise.See "keys" in perlfunc.
 $_kill

$X>$_kill($SIGNAL)
is equivalent tokill $SIGNAL, @{$X}
if$X
is an array reference andkill $SIGNAL, $X
otherwise.See "kill" in perlfunc.
 $_lc

$X>$_lc
is equivalent tolc $X
.See "lc" in perlfunc.
 $_lcfirst

$X>$_lcfirst
is equivalent tolcfirst $X
.  $_length

$X>$_length
is equivalent tolength $X
.See "length" in perlfunc.
 $_link

$X>$_link($Y)
is equivalent tolink $X, $Y
.See "link" in perlfunc.
 $_localtime

$X>$_localtime
is equivalent tolocaltime $X
.  $_log

$X>$_log
is equivalent tolog $X
.See "log" in perlfunc.
 $_lstat

$X>$_lstat
is equivalent tolstat $X
.See "lstat" in perlfunc.
 $_map

$X>$_map($F)
is equivalent to[ map $F>($_), @{$X} ]
, i.e. it takes and returns an array reference. The function$F
is passed the current element as an argument.See "map" in perlfunc.
 $_mkdir

$X>$_mkdir
is equivalent tomkdir $X
.See "mkdir" in perlfunc.
 $_oct

$X>$_oct
is equivalent tooct $X
.See "oct" in perlfunc.
 $_ord

$X>$_ord
is equivalent toord $X
.See "ord" in perlfunc.
 $_pack

$X>$_pack($FORMAT)
is equivalent topack $FORMAT, @{$X}
if$X
is an array reference andpack $FORMAT, $X
otherwise.See "pack" in perlfunc.
 $_pop

$X>$_pop
is equivalent topop @{$X}
.See "pop" in perlfunc.
 $_pos

$X>$_pos
is equivalent topos $X
.$X>$_pos($Y)
is equivalent topos($X) = $Y
.See "pos" in perlfunc.
 $_prototype

$X>$_prototype
is equivalent toprototype $X
.  $_push

$X>$_push(@VALUES)
is equivalent topush @{$X}, @VALUES
.See "push" in perlfunc.
 $_quotemeta

$X>$_quotemeta
is equivalent toquotemeta $X
.  $_rand

$X>$_rand
is equivalent torand $X
.See "rand" in perlfunc.
 $_readlink

$X>$_readlink
is equivalent toreadlink $X
.  $_ref

$X>$_ref
is equivalent toref $X
.See "ref" in perlfunc.
 $_rename

$X>$_rename($Y)
is equivalent torename $X, $Y
.See "rename" in perlfunc.
 $_require

$X>$_require
is equivalent torequire $X
.  $_reverse

$X>$_reverse
is equivalent to[ reverse @{$X} ]
if$X
is an array reference andscalar reverse $X
otherwise.  $_rindex

$X>$_rindex($NEEDLE)
is equivalent torindex $X, $NEEDLE
.$X>$_rindex($NEEDLE, $OFFSET)
is equivalent torindex $X, $NEEDLE, $OFFSET
.See "rindex" in perlfunc.
 $_rmdir

$X>$_rmdir
is equivalent tormdir $X
.See "rmdir" in perlfunc.
 $_shift

$X>$_shift
is equivalent toshift @{$X}
.See "shift" in perlfunc.
 $_sin

$X>$_sin
is equivalent tosin $X
.See "sin" in perlfunc.
 $_sleep

$X>$_sleep
is equivalent tosleep $X
.See "sleep" in perlfunc.
 $_sort

$X>$_sort
is equivalent to[ sort @{$X} ]
.$X>$_sort($CMP)
is equivalent to[ sort { $CMP>($a, $b) } @{$X} ]
.See "sort" in perlfunc.
 $_splice

$X>$_splice
is equivalent tosplice @{$X}
.$X>$_splice($OFFSET)
is equivalent tosplice @{$X}, $OFFSET
.$X>$_splice($OFFSET, $LENGTH)
is equivalent tosplice @{$X}, $OFFSET, $LENGTH
.$X>$_splice($OFFSET, $LENGTH, @VALUES)
is equivalent tosplice @{$X}, $OFFSET, $LENGTH, @VALUES
.See "splice" in perlfunc.
 $_split

$X>$_split
is equivalent to[ split ' ', $X ]
.$X>$_split($REGEX)
is equivalent to[ split $REGEX, $X ]
.$X>$_split($REGEX, $LIMIT)
is equivalent to[ split $REGEX, $X, $LIMIT ]
.See "split" in perlfunc.
 $_sprintf

$X>$_sprintf($FORMAT)
is equivalent tosprintf $FORMAT, @{$X}
if$X
is an array reference andsprintf $FORMAT, $X
otherwise.See "sprintf" in perldoc.
 $_sqrt

$X>$_sqrt
is equivalent tosqrt $X
.See "sqrt" in perlfunc.
 $_srand

$X>$_srand
is equivalent tosrand $X
.See "srand" in perlfunc.
 $_stat

$X>$_stat
is equivalent tostat $X
.See "stat" in perlfunc.
 $_substr

$X>$_substr($OFFSET)
is equivalent tosubstr $X, $OFFSET
.$X>$_substr($OFFSET, $LENGTH)
is equivalent tosubstr $X, $OFFSET, $LENGTH
.$X>$_substr($OFFSET, $LENGTH, $REPLACEMENT)
is equivalent tosubstr $X, $OFFSET, $LENGTH, $REPLACEMENT
.See "substr" in perlfunc.
 $_symlink

$X>$_symlink($Y)
is equivalent tosymlink $X, $Y
.  $_syscall

$X>$_syscall(@ARGS)
is equivalent tosyscall $X, @ARGS
.  $_system

$X>$_system(@ARGS)
is equivalent tosystem { $X } @ARGS
.$X>$_system
is equivalent tosystem @{$X}
if$X
is an array reference andsystem $X
otherwise.See "system" in perlfunc.
 $_truncate

$X>$_truncate($Y)
is equivalent totruncate $X, $Y
.  $_uc

$X>$_uc
is equivalent touc $X
.See "uc" in perlfunc.
 $_ucfirst

$X>$_ucfirst
is equivalent toucfirst $X
.  $_umask

$X>$_umask
is equivalent toumask $X
.See "umask" in perlfunc.
 $_unlink

$X>$_unlink
is equivalent tounlink $X
.See "unlink" in perlfunc.
 $_unpack

$X>$_unpack($FORMAT)
is equivalent tounpack $FORMAT, $X
.See "unpack" in perlfunc.
 $_unshift

$X>$_unshift(@VALUES)
is equivalent tounshift @{$X}, @VALUES
.  $_utime

$X>$_utime($ATIME, $MTIME)
is equivalent toutime $ATIME, $MTIME, @{$X}
if$X
is an array reference andutime $ATIME, $MTIME, $X
otherwise.See "utime" in perlfunc.
 $_values

$X>$_values
is equivalent to[ values @{$X} ]
if$X
is an array reference and[ values %{$X} ]
otherwise.See "values" in perlfunc.
 $_vec

$X>$_vec($OFFSET, $BITS)
is equivalent tovec $X, $OFFSET, $BITS
.$X>$_vec($OFFSET, $BITS, $REPLACEMENT) is equivalent to c<< vec($X, $OFFSET, $BITS) = $REPLACEMENT
.See "vec" in perlfunc.
 $_waitpid

$X>$_waitpid
is equivalent towaitpid $X, 0
.$X>$_waitpid($FLAGS)
is equivalent towaitpid $X, $FLAGS
.  $_warn

$X>$_warn
is equivalent towarn $X
.See "warn" in perlfunc.
SEE ALSO
AUTHOR
Lukas Mai, <l.mai at web.de>
COPYRIGHT & LICENSE
Copyright 20132014 Lukas Mai.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.