x1=2; x2=3; x3=4;
y1=3; y2=5; y3=7;
z1=4; z2=7; z3=10;
####
#!usr/bin/perl-w
print"\n Type the name of data file: ";
$data=;
chomp $data;
unless (open (DATA,$data)){
print "\n\n Couldn't open file $data.";
}
my %vals;
while ( ) {
my ($identifier,$value) = split /\s*=\s*/;
$vals {$identifier} = $value;
}
close DATA;
$calculation1=$vals{x1}*$vals{y1};
print"\n\n 1st result=$calculation1;\n\n";
exit;
####
C:\Users\xyz\Desktop>d6.pl
Type the name of data file: data.txt
1st result=6;
####
#!usr/bin/perl-w
print"\n Type the name of data file: ";
$data=;
chomp $data;
unless (open (DATA,$data)){
print "\n\n Couldn't open file $data.";
}
my %vals;
while ( ) {
my ($identifier,$value) = split /\s*=\s*/;
$vals {$identifier} = $value;
}
close DATA;
$calculation1=$vals{x1}*$vals{y1};
$calculation2=($vals{x1}*$vals{y1})/($vals{x2});# Line 15
print"\n\n 1st result=$calculation1;\n\n
2nd result=$calculation2";
exit;
####
C:\Users\xyz>cd desktop
C:\Users\xyz\Desktop>d5.pl
Type the name of data file: data.txt
Illegal division by zero at C:\Users\xyz\Desktop\d5.pl line 15.
####
1st result=6;
2nd result=2;