Files
Makefile-tutorial/perl/wiki
2025-02-21 08:00:02 +00:00

100 lines
2.8 KiB
Plaintext

-> Perl is weakly typed language.
$a=10;
$b="a";
$c=$a.$b;
print $c;
output:
10a
-> It follows both procedural and object oriented paradigm.
Ex: Csc01BuildUnit.pm -> Base class = Build.pm
^ ^
| |
Derived class Base class
With .pm extension is for perl module
-> Perl is interpreted language, but as compare to interpreted language like
bash, etc, perl can be compiled to bytecode.
-> Perl can support .pl or .PL extension, but not restricted to these only
can also use .pm extension, which used in Tejas Networks.
-> '#!/usr/bin/env perl':
Will search for perl in $PATH environment variable from shell and then run from
that
The path mentioned is path for binary 'env' which is used to find
exectuable for perl
Use command 'which perl' to find the location of perl
-> '#!/usr/bin/perl':
This will be used in direct path for perl exectuable( absence of this
can lead to error.)
flags:
-d: debugging mode(suboption: next, run, step, print, etc).
* h: help
* run: start execution
* next: next line
* step: follow function call if there
* print: non-nested printing
* x: nested printing of objects, data structures, etc
* b: set break points
* c: continue
-I Directory: (include directory): Specifies @INC
It add specific directories to @INC array
-w: Shows important warnings
-W: Shows all warnings
-X: Disable all warnings
@INC: It is a array of include directory.
While running the scripts, we might see this in error logs.
This means that some include directories are missing.
-> -e "program": Runs perl script sent in as a program(Interactive mode
programming). To run a one liner perl command use -e flag
perl -e 'print "Hello World\n"'
Output: Hello World
-> eval perl: To run multi line perl command use eval perl.
For example:
eval perl
@a = ('csc01', 'csc02', 'cef8');
print @a, "\n";
print "@a\n";
CTRL+D
-> -t && -T && -U: For security & taint check/warnings.
* -T: check for unsecure operation tainting in given perl script
and treat them as fatal errors. Stop the scripts
* -t: small brother of -T, run the scripts with warnings
* -U: Allow unsecure and run scripts without warnings and errors.
-> Comments:
Begins with '#' symbol.
'#' is used for single line comment.
Multi-line comment is achieved using:
=begin
.....
comments
.....
=cut
exception:
'#!/usr/bin/perl' Shabang is not comment. It just tell
the bash that its a perl script.