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
There are two types of eval statements i.e. Eval expr and eval block. Explain them.
Explain '->' in perl?
Explain chop?
How to deleting an existing file in perl programming?
What is the purpose of “_file_ literal” and “_line_ literal” in perl?
What is qq (double q)operator in perl?
What does file test operators do in perl?
What are hashes?
What is the difference between use and require in perl?
You want to read command-line arguements with perl. How would you do that?
How can arrays be tied?
Why to use perl?
What are the reasons that cookie server can’t handle multiple connections?
How to add elements in a hash in perl?
Explain what is lvalue?