Perl Data Structures - Accessing Arrays of Arrays
Method 1:
@array=(["apple","orange"],
["Mango","Banana"],
["Papaya","Peach"]
);
$arrayref = $array[1];
print ${$arrayref}[1];
Read more »
[There's More Than One Way To Do It]
Always A Blog To Get Confident in Coding
Method 1:
@array=(["apple","orange"],
["Mango","Banana"],
["Papaya","Peach"]
);
$arrayref = $array[1];
print ${$arrayref}[1];
Read more »
Perl hash of hashes is a data structure that consists of a hash that contains other hashes as values. Each hash contained in the main hash can be accessed using a unique key.
Here's an example of how to create a hash of hashes in Perl:
my %HoH = ( 'John' => { 'age' => 35, 'occupation' => 'Programmer', 'salary' => 50000, }, 'Mary' => { 'age' => 27, 'occupation' => 'Designer', 'salary' => 40000, }, 'Mark' => { 'age' => 42, 'occupation' => 'Manager', 'salary' => 70000, }, );
Method 1:
$HoA = {
flintstones => [ "fred", "barney" ],
jetsons => [ "george", "jane", "elroy" ],
simpsons => [ "homer", "marge", "bart" ],
};
foreach (keys %{$HoA})
{
print "$_ => @{$HoA->{$_}}\n";
}
Creating Arrays of Arrays:
Method 1:
@array=(["apple","orange"],["Mango","Banana"],["Papaya","Peach"]);
print $array[0][1];
Read more »
Find Lowest Missing Numbers in perl
The given program is a Perl script designed to find the lowest missing numbers from an array of integers. The script begins by initializing an array of integers named "@arr", which contains a set of random integers. The script then creates a hash called "%hash" that maps each integer in "@arr" to the value 1.
Next, the script finds the maximum integer in "@arr" using the "sort" function and saves it to a variable named "$max". It also sets the value of the minimum integer to -1, and initializes an empty array called "@missing" to store the missing numbers.
Read more »
John","Smith", 9999 9999, "42, some street, some area", "bangalore",560038
in above strings "9999 9999" should be single string and "42, some street, some area" should be single string and 560038 should be single string remaining separate variables write perl program in multiple methods
Sure, here are three different methods to accomplish the task:
Read more »
Labels: cpan update single module, cpan upgrade perl version, how to install perl modules in linux, install perl module using cpan in linux, perl cpan install
Labels: array ref in perl, hash ref in perl, how to use ref in perl, ref in perl example, ref in perl means, ref in perl script, scalar ref in perl, strict ref
Labels: kaavannan perl blogspot, perl extract regex match, perl regex replace, perl regex substitution $1, perl replace line containing pattern, perl replace string in file command line, perl string replace