Search This Blog

Friday, July 12, 2013

PERL: BASICS Tutorial Hands on - 1

#!/usr/bin/perl #That should be the first line for any perl script in UNIX print "C:\\temp"."\n"; #To display the sentencases use print print "C:/temp"."\n"; #Escape characters like \b, \n, \r, \t etc are similar in perl as well $var1=3; #variable can be declared using $ $var2=7; #comments should start with # $var1++; #Each command should end with semicolan --$var2; #autoincrement and decrement varaible works as as usual $var3=$var1+$var2; #Arithmatic variable are also same $var3=$var1-$var2; #comments can also write at the end of line $var3=$var1*$var2; #allows single line comments only $var3=$var1/$var2; #in UNIX should be with .pl extension $var3=$var1**$var2; #power $var3=$var1%$var2; #quotient $var3 += $var2; #Assignments also works as usual $var4="Hello "; #string concatenation with . print "$var4 Hi"."\r"; print $var4 x $var1 ."\n"; # var4 is repeated var1 times #open(FILE,"$d) ? "ternary Operator" : "not working"; print $e; while($d++ < $c--) { #while loop print $d."\t".$c."\n"; } until($a==$b++) { #until loop print "until loop"; }

No comments:

Post a Comment