F
Feyruz
Hello,
i have a question about a return value in the following code (this code
is taken from a class:
sub TIESCALAR
{
my $class = shift;
$data =shift;
return bless \$data, $class;
}
What i dont understand is, why do this method return a \$data and not
$data (without reference backslash). Isn't $data already a reference?
is this a reference to a reference or? a little bit confused in that
point.
For example when we define a class, we build the constructor this way:
sub new
{
my self ={};
bless($self);
return $self;
}
and here at the end we write "return $self" and NOT "return \$self".
Why is this different?
thanks for your comments and help.
Feyruz
i have a question about a return value in the following code (this code
is taken from a class:
sub TIESCALAR
{
my $class = shift;
$data =shift;
return bless \$data, $class;
}
What i dont understand is, why do this method return a \$data and not
$data (without reference backslash). Isn't $data already a reference?
is this a reference to a reference or? a little bit confused in that
point.
For example when we define a class, we build the constructor this way:
sub new
{
my self ={};
bless($self);
return $self;
}
and here at the end we write "return $self" and NOT "return \$self".
Why is this different?
thanks for your comments and help.
Feyruz