Web Technologies
Web Technologies
Web Technologies
Perl –d
2) #! /usr/bin/perl
3) $c= 10;
$f = 9/5*$c+32;
4) #!/usr/bin/perl
use strict;
use warnings;
my $i=10;
my $j=10;
for(my $i=0; $i<=5; $i++)
5) #!/usr/bin/perl
use strict;
use warnings;
my $i=10;
my $j=10;
if($i%2==0)
else
6) #!/usr/bin/perl
use strict;
use warnings;
my $i=10;
if($j%2==0)
else
}
7) #!/usr/bin/perl
use strict;
use warnings;
my $i=10;
if($j%2==0)
else
my $filename='C:\Users\Karan\Documents\triangles.dat';
OUTPUT:
8) #!/usr/bin/perl
use strict;
use warnings;
my $k;
my $l;
my $s;
my $u;
my $r;
my $format =<STDIN>;
my $weight=<STDIN>;
if($format = "Stones")
my $k=$weight*6.35;
elsif($format ="Pounds")
my $l=$weight*0.45;
elsif($format ="Ounces")
my $u=$weight*0.028;
my $hf=<STDIN>;
print"Enter Height";
my $height=<STDIN>;
if($hf="Meter")
my $s=$height;
elsif($hf="Inches")
{
my $r=$height*0.025;
my $bmi= $k/($s**2);
print "$bmi";
my $bmi5= $l/($s**2);
print "$bmi5";
my $bmi4= $u/($s**2);
print "$bmi4";
my $bmi3= $k/($r**2);
print "$bmi3";
my $bmi2= $l/($r**2);
print "$bmi2";
{
my $bmi1= $u/($r**2);
print "$bmi1";
OUTPUT:
9) my $filename='C:\Users\Karan\Documents\3.pl';
OUTPUT:
10) #!/usr/bin/perl
use warnings;
my $filename='C:\Users\Karan\Documents\3.pl';
my $string = "apple";
while (<FILE>) {
if (/$string/)
else
OUTPUT:
11. #!/usr/bin/perl
use warnings;
chomp(my $cel=<STDIN>);
while($cel==0){
$f=(9*$cel/5+32);
OUTPUT:
12)
my $name=<STDIN>;
chomp($name);
@arr=split(//,$name);
$count=@arr;
$num=0;
#print $count;
for ($i=0;$i<$count;$i++){
if ($arr[$i] eq $arr[$count-1]){
$count--;
}else{
$num++;
last;
if ($num == 0){
}else{
OUTPUT:
18)
#!/usr/bin/perl
use strict;
use warnings;
my $file_name = <STDIN>;
chomp($mark);
chomp($file_name);
open (my $fh, '<', $file_name) or die "Can't Open $file_name $!\n";
print"$line";
else
print"<CODE> $line";
OUTPUT:
19) #!/usr/bin/perl
use strict;
use warnings;
my $file_name = <STDIN>;
chomp($file_name);
chomp($median);
open (my $fh, '<', $file_name) or die "Can't Open $file_name $!\n";
20.
#!/usr/bin/perl
use strict;
use warnings;
my $file_name = <STDIN>;
chomp($file_name);
open (my $fh, '<', $file_name) or die "Can't Open $file_name $!\n";
my $DESIRED_LINE_NUMBER1 = 1;
my $DESIRED_LINE_NUMBER2 = 2;
my $LINE = $line[$DESIRED_LINE_NUMBER1];
my $LINE2 = $line[$DESIRED_LINE_NUMBER2];
chomp($product);
print"$line";
OUTPUT:
24)
1) /Fred/
2) /[Fred Bloggs]/
3) preg_match( '/^[A-Z0-9]{10}$/')
4) preg_match( '/^[A]{10}$/')