Questions about this topic? Sign up to ask in the talk tab.
Perl/Basics/Variables and Data Types/Casting
From NetSec
Revision as of 02:33, 16 July 2012 by AlizaLorenzo (Talk | contribs) (Created page with "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 @). * ...")
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); |