Perl Programming Question:
Does Perl have reference type?

Answers:
Answer #1
Yes. Perl can make a scalar or hash type reference by using backslash operator.
For example
$str = "here we go"; # a scalar variable
$strref = $str; # a reference to a scalar
@array = (1..10); # an array
$arrayref = @array; # a reference to an array
Note that the reference itself is a scalar.
Yes. Perl can make a scalar or hash type reference by using backslash operator.
For example
$str = "here we go"; # a scalar variable
$strref = $str; # a reference to a scalar
@array = (1..10); # an array
$arrayref = @array; # a reference to an array
Note that the reference itself is a scalar.
Answer #2
Yes.
EX:
##need backslash to the operator
my $var = 6767;
my $ref = $var;
print "The reference of $var is $ref";
Yes.
EX:
##need backslash to the operator
my $var = 6767;
my $ref = $var;
print "The reference of $var is $ref";
Previous Question | Next Question |
What is the difference between /^Foo/s and /^Foo/? | How to dereference a reference? |