Uploaded by vinay chitare

module1 sess1

advertisement
#!/usr/bin/perl
use 5.010;
use strict;
use warnings;
print "hello world\n";
print "welcome to perl\n";
#case sensitive
#scalar variable uses sigil$
#array uses sigil@
#array uses sigil#
#the type of the variable is understood by value assigned to the variable, there is no need of decl the type of the variable.
#we use sigil_nameofvariable = value of the variable to declare the variables.
my$name ="vinay";
my$num = 10;
my$decimal = 3.142;
print $name,"\n";
print $num,"\n";
print $decimal,"\n";
#-------------------------numbers in perl------------------------------
my$int =10;
print $int,"\n";
my$negint =-10;
print $negint,"\n";
my$floating =22.542658;
print $floating,"\n";
my$sn =10e22;
print $sn,"\n";
my$hex =0x000f;
print $hex,"\n";
my$oct =072;
print $oct, "\n";
#-----------------strings in perl---------------------------
# combine string variable using cooma
#print $var1,$var2,\n;
#escape character \n--new line ,\b-- back space,\t-- horizontal tab,\h--vertical tab
my $var1 ="hello";
my $var2 = 'world';
print $var1,$var2,"\n";
print $var1,"",$var2,"\n";
print "hello\world\n";
print "hello\\world\n";
my $vara1 =10;
my $vara1 =20.12;
print $vara1,"\n";
print $vara1,"\n";
#empty string is used for later usage
#undef string is used for short time and empty it later
#------------------------namespace &scope--------------------------------
package hello;
sub sayit {
return "hello";
}
package world;
sub sayit {
return "world";
}
package main;
say hello::sayit();
say world::sayit();
Download