How can you create an object of a class in a package?
Answer Posted / sh faisal
package Test;
sub new
{
$class = shift;
$self = {};
bless $self,$class; # By Mistake earlier i wrote it as
#$ref
return $self;
}
1;
# In perl Script
use Test; # Include the module you have created
$obj=new Test; # creating an onject of Class Test
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Explain the various characteristics of perl.
Explain grooving and shortening of arrays and splicing of arrays?
What are the steps involved when the cgi program starts running?
Explain regular expression in perl?
What is a perl references?
Mention the difference between die and exit in Perl?
List all the features of perl programming?
Explain lists ?
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
How to open and read data files with Perl
what is perl language?
Which guidelines by Perl modules must be followed?
Is perl compiler or interpreter?
How to remove a directory in perl?
Demonstrate subroutines in perl with a simple example.