Sys Verilog
Sys Verilog
/usr/bin/perl
=pod
print "enter a number through standard input\n";
my $a=<STDIN>;
chop($a);
print $a . "\n";
=cut
#hex function
my $a=0x2e;
my $r=hex($a);
print $r;
#oct function
=pod
my $c1=0x2e; #hexadecimal
my $a=oct($c1);
print $a ."\n";
my $c2=057; #Octal format
my $a2=oct($c2);
print $a2 . "\n";
=cut
=pod
my $p=10;
my $str=sprintf("%lx",$p);
my $str1=sprintf("%lo",$p);
my $str2=sprintf("%lb",$p);
my $str3=sprintf("%lf",$p);
my $str4=sprintf("%e",$p);
print $str . "\n";
print $str1 ."\n";
print $str2 . "\n";
print $str3 . "\n";
print $str4 . "\n";
=cut
#example of sqrt
=pod
my $a=sqrt(16);
print $a;
=cut
#int function..
=pod
my $price=9.95;
my $dollar=int($price);
print $dollar;
=cut
=pod
my $a=-3.4;
my $b=abs($a);
print $b;
=cut
=pod
#to remove
#my @a1=splice(@a,1,1);
#to add
splice(@a,2,0,'king','manohar');
print "@a" . "\n";
=cut
=pod
#print "@reverse";
=cut
=pod
=pod
my $i=15;
my $j=12;
=pod
my $decimal=12;
my $hex=sprintf("%08lx",$decimal);
my $oct=sprintf("%08lo",$decimal);
my $bin=sprintf("%08lb",$decimal);
=cut
=pod
my $str=<<'endofstring';
brajesh
rajesh
rakesh
anitha
ana
endofstring
print $str;
=cut
#join function
=pod
my $str=join(" and ",qw(raju rajesh ana prankaj));
#print $str;
#or
my $str=join(" and ", 'raju','rajesh','ana','pankaj');
print $str;
=cut
#split function
#
=pod
my $data='raju\brajesh\ana\bhushan';
my ($fname,$sname,$tname,$foname)= split(/\\/,$data);
print "firstname is $fname\n";
print "secondname is $sname\n";
print "thirdname is $tname\n";
print "fourth name is $foname\n";
=cut
=pod
my $i="welcome to incise";
my $j=substr($i,8,4);
print $j."\n";
=cut
#string concatenation
=pod
my $str="raju"." rajesh";
print $str;
=cut
=pod
my $str="raju " x 5;
print " $str";
=cut
#chomp($i);
print " i is $i\n";
chop($i);
print " i is $i\n";
=cut
##########################variable interpolation
=pod
my $i=5;