How can you create an object of a class in a package?
Answer Posted / shah faisal
package Test;
sub new
{
$class = shift;
$self = {};
bless $ref,$class;
return $ref;
}
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 ? | 2 Yes | 3 No |
Post New Answer View All Answers
What is a perl references?
How to start perl in interactive mode?
What is the use of '>>' in perl?
Distinguish my and local?
How do I replace every TAB character in a file with a comma?
Explain join function in perl?
You want to download the contents of a url with perl. How would you do that?
How do I send e-mail from a Perl/CGI program on a Unix system?
Who created perl?
Elaborate on perl bite-wise operators.
Explain what is lvalue?
How do you give functions private variables that retain their values between calls?
How to code in perl to implement the tail function in unix?
Which has the highest precedence, List or Terms? Explain?
What is the use of now constructor in perl?