Reference single array element by using the $ not @ : Array Scalar « Array « Perl






Reference single array element by using the $ not @

    

#!/usr/bin/perl -w

use strict;

my @array = (1, 3, 5, 7, 9);
print @array[1];
print $array[1];

   
    
    
    
  








Related examples in the same category

1.Convert array to scalar
2.Assigning An Array To A Scalar
3.Use a scalar variable as our subscript:
4.Assign array variable to scalar variable
5.Split a scalar to create a list
6.Assign array value to a list of scalar variables
7.Assigning an array value to a scalar variabe
8.Scalar Data in an Array
9.Place scalar variables in lists and arrays.