0% found this document useful (0 votes)
24 views

Perl Additionalslides

The document discusses complex data structures in Perl including arrays of arrays and arrays of hashes. It also provides information on debugging Perl code using the perl debugger and examples of lookahead and lookbehind assertions.

Uploaded by

baskar910
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Perl Additionalslides

The document discusses complex data structures in Perl including arrays of arrays and arrays of hashes. It also provides information on debugging Perl code using the perl debugger and examples of lookahead and lookbehind assertions.

Uploaded by

baskar910
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Complex Data structures

Array of Arrays
@a=(100,200,300);
@b=('mango','apple','orange');
@AoA=(\@a,\@b);
@AoA=([100,200,300],['mango','apple','orange'])

foreach $element (@AoA)


{
print @{$element},\n;

}
foreach $element(@AoA)
{
foreach $e (@{$element})

{
print $e\n;

print \n;

}
t

Array of Hashes

%h1=('empno'=>100,'age'=>30);
%h2=('mango'=>'yellow','apple'=>'red');
@AoH=(\%h1,\%h2);

foreach $hash (@AoH)

{
foreach $key (keys %{$hash})
{
print $key = , $hash->{$key}, \n;
}

print \n;

Debugging Perl

perl -d ./perl_debugger.pl

l 10 view specific lines

l function view function

b function set break points on the function

b 44

n steps over

s steps into

Look ahead/behind assertions

#!/usr/bin/perl

$string="Monday Tuesday Wednesday Thursday Friday";

if($string =~ m/Monday\s(?=Tuesday)/)

print "positive lookahead\n";

if ($string =~ m/(?<=Wednesday)\sThursday/)

print "positive lookbehind\n";

You might also like