Professional Documents
Culture Documents
Packages & Modules: Ex. No: 8 23/03/2011
Packages & Modules: Ex. No: 8 23/03/2011
Packages & Modules: Ex. No: 8 23/03/2011
29SCS124
Ex. No: 8
PACKAGES & MODULES
23/03/2011
Aim:
To write a PERL program to demonstrate the concept Packages & Modules.
Algorithm:
Creating and Using Perl Package
iii) The programmer calls the subroutines by using a double colon (::). And these
subroutines can be used within other packages.
Program:
Package (Arith.pm)
package Arith;
require Exporter;
@ISA=qw(Exporter);
sub Hello
sub Welcome
return $c;
sub product
$a=$_[0];
$b=$_[1];
$c=$a*$b;
sub divide
$a=$_[0];
$b=$_[1];
Priyankar Paul 3
29SCS124
$c=$a/$b;
return $c;
Program (Operations.pl)
Hello;
$x=Welcome;
print "$x";
$y=<stdin>;
$z=<stdin>;
&product($y,$z);
$ans=÷($y,$z);
Output:
Hello world!
Enter 2 numbers
23
4
Product = 92
Result:
Thus the PERL program to demonstrate the concept of Packages and Modules was
successfully executed and its output was verified.