Horje
perl access elements of an array Code Example
perl access elements of an array
# Basic syntax:
my $array_element = $your_array[array_index];
# Note, Perl's use of sigils ($, @, %) can be a little confusing. Even though
# 	your_array is an array, when accessing a single element it's essentially
#	a scalar so you use $ both for the array and the new variable

# Example usage:
# Define array
my @your_array = (2.3, 42, 'Word');
# Select 2nd element (zero-indexed)
my $array_element = $your_array[2];
print "$array_element\n";
--> Word




14

Related
perl compare strings Code Example perl compare strings Code Example
perl match pattern Code Example perl match pattern Code Example
perl match regex Code Example perl match regex Code Example
perl compare scalars Code Example perl compare scalars Code Example
perl hash operations Code Example perl hash operations Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
16