Assign array value to a list of scalar variables : Array Scalar « Array « Perl






Assign array value to a list of scalar variables

    

#!/usr/bin/perl -w

my $scalar0; 
my $scalar1; 
my $scalar2;

my @array = (10, 20, 30);

($scalar0, $scalar1, $scalar2) = @array;

print "Scalar zero is $scalar0\n";
print "Scalar one is $scalar1\n";
print "Scalar two is $scalar2\n";

   
    
    
    
  








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.Assigning an array value to a scalar variabe
7.Reference single array element by using the $ not @
8.Scalar Data in an Array
9.Place scalar variables in lists and arrays.