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
What does next statement do in perl?
Create a function that is only available inside the scope where it is defined ?
How do I print the entire contents of an array with Perl?
Explain use of ‘my’ keyword in perl?
Explain perl one-liner?
What is warn function in perl?
What is -> symbol in perl?
What are scalars?
How can you replace the characters from a string and save the number of replacements?
Give an example of the -i and 0s option usage.
What is the easiest way to download the contents of a URL with Perl?
What happens to objects lost in "unreachable" memory, such as the object returned by Ob->new() in `{ my $ap; $ap = [ Ob->new(), $ap ]; }' ?
Explain the functioning of conditional structures in perl.
Explain what is STDIN, STDOUT and STDERR?
What exactly is grooving and shortening of the array?