Tags » Perl

Perl - Understanding execution pattern of BEGIN, CHECK and INIT blocks

Consider the following perl program and predict it’s output:

   

    #!/usr/bin/perl -l
    print       "start main running here";
    die         "main now dying here\n";
    die         "XXX: not reached\n";
    END         { print "1st END: done running"   }
    CHECK       { print "1st CHECK: done compiling" }
    INIT        { print "1st INIT: started running"  }
    END         { print "2nd END: done running"   }
    BEGIN       { print "1st BEGIN: still compiling" }
    INIT        { print "2nd INIT: started running"  }
    BEGIN       { print "2nd BEGIN: still compiling" }
    CHECK       { print "2nd CHECK: done compiling" }
    END         { print "3rd END: done running"   }

… 293 more words
Perl

How do we create a website in Perl?

How do we create a website in Perl?

In these times, Perl web programming may have taken a back with the more modern and trendy implementation such as Java, PHP, Ruby and others. 214 more words

Perl

pl - check for args

Use this to check for the number of arguments when running a perl script

die &mati if ($#ARGV+1 ne 2);
my $arg0 = shift;
my $arg1 = shift;

sub mati {
  print "n";
  print "Usage $0 arg0 arg1n";
}

last

last label
exists the loop identified by label or in the absence of label it exists innermost loop

Perl

dereferencing

$$ref[0]
${$ref}[0] {} is jut to make it clear
$ref->[0] -> is only for single value and not for slice

Perl