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
How will you get the count of parameters passed to a perl subroutine?
What does -> symbol indicates in Perl?
List the files in current directory sorted by size ?
Is perl a case sensitive language?
Does Perl have objects? If yes, then does it force you to use objects? If no, then why?
Explain substr function in perl?
What does this symbol mean '->'?
Write a program to decode the data in the form using cgi programming
Which operator in perl is used for the concatenation of two strings?
How to create a directory in perl?
In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?
What is qq (double q)operator in perl?
Explain lists ?
how to get back up from private character editor which is saved in the format of .udf
How do I send e-mail from a Perl/CGI program on a Unix system?