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 the use of -w, -t and strict in Perl?
Explain lists ?
Why does Perl not have overloaded functions?
What does -> symbol indicates in Perl?
What are the steps involved when the cgi program starts running?
What is the difference between die and exit in perl?
What does Perl do if you try to exploit the execve(2) race involving setuid scripts?
What does the qx{ } operator do?
what are the steps involved in reading a cgi script on the server?
How can you call a subroutine and identify a subroutine?
What is the difference between single (') and double (") quote in a string in perl?
What package you use to create a windows services?
Assuming both a local($var) and a my($var) exist, what's the difference between ${var} and ${"var"}?
What is perl pop array function?
what is Chop & Chomp function does?