Questions about this topic? Sign up to ask in the talk tab.
Difference between revisions of "Perl/Basics/Variables and Data Types/Casting"
From NetSec
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 @). * ...") |
Chantal21I (Talk | contribs) |
(No difference)
|
Latest revision as of 02:00, 19 July 2012
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); |