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


Please Help Members By Posting Answers For Below Questions

Explain socket programming in perl?

595


Explain about the applications of perl?

630


Comment on array slicing and range operator

608


Remove the duplicate data from @array=(“perl”,”php”,”perl”,”asp”)

690


Explain the various characteristics of perl.

618






How to convert arrays into a string in perl?

586


What are the various perl data types based on the context?

618


Explain goto name?

608


How do I debug a perl program?

603


What is the importance of perl warnings?

607


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

609


Explain different types of perl operators.

614


Define perl scripting?

663


Can we load binary extension dynamically?

638


How to disable the mod_perl from apache_server as i have used perlfect search on the site and its pagination is not working and the remedy is to disable the mod_perl.

1872