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
Mention what is cpan?
List the data types that Perl can handle?
How does a “grep” function perform?
How will you declare a variable in perl?
List the prefix dereferencer in Perl.
There are two types of eval statements i.e. Eval expr and eval block. Explain them.
What is perl shift array function?
Explain what is STDIN, STDOUT and STDERR?
Differentiate use and require?
what is Chop & Chomp function does?
What is the function of cgiwrap in cgi programming?
How can you call a subroutine and identify a subroutine?
What is epoch time in perl?
What are the two ways to get private values inside a subroutine?
What $! In perl?