| Previous | Next
Scalar::UtilImplements a few useful scalar-related subroutines. Like List::Util, Scalar::Util is something useful that doesn't necessarily fit well as a keyword in the Perl core. By default, Scalar::Util does not export any subroutines. As of Perl 5.8, Scalar::Util is shipped with the source kit. Scalar::Util implements the following methods.
blessed expr Evaluates whether expr is a blessed reference. If successful,
dualvar number, string Returns a string that has the value numberin a numeric context and a value string in a string context. For example: my $context = dualvar(10, "Nathan"); my $add_nums = $context + 1; # '11' my $str_add = $context . "Patwardhan"; # Nathan Patwardhan
isweak expr Returns true if expr is a scalar, which is a weak reference: my $weak_ref = \$boo_hoo; my $i_am_weak = isweak($weak_ref); # false weaken($weak_ref); $i_am_weak = isweak($weak_ref); # true
openhandle fh Returns
readonly scalar Returns true if scalar is read-only.
reftype expr Returns the reference type of expr if expr is a reference. Otherwise, returns my $r_type = reftype "ORA"; # undef, not a reference my $r_type = reftype []; # ARRAY
tainted expr Returns true if the result of expr is tainted:
weaken ref Returns ref into a weak reference. When the reference count on an object reaches 0, |