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


Please Help Members By Posting Answers For Below Questions

How will you get the count of parameters passed to a perl subroutine?

530


What does -> symbol indicates in Perl?

555


List the files in current directory sorted by size ?

516


Is perl a case sensitive language?

626


Does Perl have objects? If yes, then does it force you to use objects? If no, then why?

538






Explain substr function in perl?

532


What does this symbol mean '->'?

525


Write a program to decode the data in the form using cgi programming

538


Which operator in perl is used for the concatenation of two strings?

488


How to create a directory in perl?

518


In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?

577


What is qq (double q)operator in perl?

547


Explain lists ?

522


how to get back up from private character editor which is saved in the format of .udf

1835


How do I send e-mail from a Perl/CGI program on a Unix system?

579