Array
Perl Array of Arrays:
Array of arrays allow us to use arrays within an array. This is a two-dimensional data structure that is quite often used in the perl environment.
Perl array can have multiple arrays referenced within it.
Perl Array of Arrays Example:
@perl_array_of_arrays = ( [ "perl_array_element_1", "perl_array_element_2", "perl_array_element_3" ],
[ 4, 5, 6, 7 ],
[ "perl_array_element_alpha", "perl_array_element_beta" ]
);
Perl Push appends a list to the right side of an array. It returns the number of elements of the array after pushing. Perl push is opposite to perl pop or perl shift function. Perl pop removes the last element of an array.
Perl Push Syntax
push (array, list)
Perl Push Examples
!/usr/bin/perl
use strict;
use warnings;
my @array = (1, 2, 3, 4);
my $size = push (@array, (5, 6, 7));
print "\$size = $size, \@array = @array\n";
This would output following:
$size = 7, @array = 1 2 3 4 5 6 7
1 answers
How can I find the length of an Array?
.......... Nancy from Illionois
Read more »
Created by Anonymous
20 weeks 5 hours ago
Tags:
1 answers
All,
I have an array whereby each element in that array is of the following format:
@myNames = ('a b', 'c d', 'e f', 'g h', 'i j');
However, I am only interested in grepping the second part of each element - i.e. b, d, f, h and j.
How do I grep for second part? Would Map be helpful?
I get the entire element returned and not the section of that element that I am after.
Read more »
Created by Anonymous
20 weeks 6 days ago
Tags: