ecmm6018 enterprise networking for electronic commerce tutorial 5 server side scripting perl
TRANSCRIPT
![Page 1: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/1.jpg)
ECMM6018 ECMM6018 Enterprise Networking For Electronic Enterprise Networking For Electronic
CommerceCommerceTutorial 5Tutorial 5
Server Side Scripting
Perl
![Page 2: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/2.jpg)
What is itWhat is it
Server Side Language Cgi application resides in the /cgi-bin directory #! /opt/bin/perl Use CGI qw(:standard) ASP, JSP
![Page 3: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/3.jpg)
Variable Types in PerlVariable Types in Perl Scalar variable : Scalar variables used to contain strings, integer
Numbers and floating point numbers (decimals)
e.g. $varname
Indexed array: A variable that can store different scalar values,e.g. numbers, decimals
e.g. @arrayname
accessed $arrayname[i]
Associative array: elements of an associative array are referred to as
"key" and "value" pairs
e.g. %array
accessed $array{key} = pair
Variable names should be restricted to just letters of the alphabet, i.e. leave out characters such as !, @, #, $, %, ^, &, *, (, ), ~
![Page 4: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/4.jpg)
Mathematical OperatorsMathematical Operators
+ Addition - Subtraction * Multiplication / Division ++ Adds one to the value on the left, i.e. j++, j=j+1 -- Subtracts one from the value on the left j--, j= j-1
![Page 5: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/5.jpg)
Assignment Operators Assignment Operators
= Assigns what is on the right side to what is on the left e.g. a=3
+= Adds the value of the right side to the left side and
makes the variable on the left equal to it. e.g. a +=3, a=a+3 -= Subtracts the value of the right side to the left side and
makes the variable on the left equal to it. e.g. a-=3, a=a-3
![Page 6: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/6.jpg)
Comparison OperatorsComparison Operators
< > <= >= == eq != Ne =~
![Page 7: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/7.jpg)
Conditional StatementConditional Statement
If If – Else
If (condition) { statement } e.g. if ($a!=5) { print “Answer is not 5\n”; }
![Page 8: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/8.jpg)
Conditional StatementConditional Statement
If-Else If (condition)
statement
Else
statement
e.g. if ($a!=5)
{
print “Answer is not 5\n”;
}
else
print “Answer is 5\n”;
![Page 9: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/9.jpg)
Conditional StatementConditional Statement
if ($stuff < 5) { print “short!\n"; } elsif ($stuff >= 6) { print “tall!\n"; } else { print “in between\n"; }
![Page 10: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/10.jpg)
LoopingLooping
WhileForForeach
![Page 11: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/11.jpg)
While StatementWhile Statement
while (condition) { code to be executed }
e.g. while ($stuff <6) { print “$stuff\n”; $stuff++; }
![Page 12: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/12.jpg)
For StatementFor Statement
for (initialization; test condition; increment)
{
code to be executed
}
for ($i = 0; $i <= $#stuff; $i++)
{
print "$stuff[$i]";
}
![Page 13: ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl](https://reader036.vdocuments.site/reader036/viewer/2022082818/56649ed35503460f94be3523/html5/thumbnails/13.jpg)
For EachFor Each Statement Statement
foreach $slotspace (@stuff)
{
print "$slotspace";
}
foreach $slotname (keys (%stuff)) { print "$stuff{$slotname}"; }