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
What are the advantages of perl programming?
Which functions in perl allows you to include a module file. State their differences.
Explain chop?
Mention how many ways you can express string in Perl?
How do I pass a command line argument in perl?
What is a chomp() function in perl?
How to determine strings length in perl?
What does last statement do in perl?
Explain chomp?
What does init 5 and init 0 do?
What is the purpose of goto expr statement?
What is eval function in perl?
How can you use Perl warnings and what is the importance to use them?
In Perl, what is grep function used for?
What are the arguments and what do they mean in perl programming?