Questions about this topic? Sign up to ask in the talk tab.
Perl/Basics/Variables and Data Types/Casting
From NetSec
(Redirected from Perl casting)
Casting is the process of transitioning from one data type to another. This is typically done using curly brackets {} preceeded by a data type designator ($,%, or @).
- To cast a hash reference back to a hash:
my %hash; my $hashref = \%hash; #create the hash reference my %casted = %{$hashref}; #Cast back to a hash. |
- To cast a list of keys in a hash into an array:
my @casted = @{keys %hash}; |
- To cast a scalar value to an integer:
my $integer = int($scalar); |