Basic Perl Datatypes : Data Type « Data Type « Perl






Basic Perl Datatypes

   

#Scalars are always prefixed with $, 
#arrays with an @, and 
#hashes with a %. 

If something is a variable, and it doesn't have a special character in front of it, it might be a filehandle. 

        
Special Character       What it Denotes     Example 
$                       Scalar              $number = 123.44; $string = 'aaaa';   
@                       Array               @numberArray =(1,2,3);  
                                            @stringArray = ('elmt1', 'elmt2',3 );   
$<var>[ ]               Array Element       print $stringArray[2]; 
                                            $stringArray[4] = 'newstring';
%                       Hash                %hashName = ('key' => 'value', 'key2'=>'value2');   
$<var>{ }               Hash Lookup         print $hashName{'key'};        # prints 'value' 
                                            $hashName{'key3'} = 'value3';  # sets 'key3'    

   
    
    
  








Related examples in the same category

1.Number can be expressed by ###_###_### for ###,###,###
2.Number systems
3.Numeric Literal Formats and Notation
4.Numeric Literals
5.Perl 5 Numeric Formats
6.Using Numbers in Scalar Variables