Sunteți pe pagina 1din 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";

S-ar putea să vă placă și