Perl Programming Question:
Download Questions PDF

Does Perl have reference type?

Perl Programming Interview Question
Perl Programming Interview Question

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.

Answer #2
Yes.
EX:
##need backslash to the operator
my $var = 6767;
my $ref = $var;
print "The reference of $var is $ref";

Download Perl Programming Interview Questions And Answers PDF

Previous QuestionNext Question
What is the difference between /^Foo/s and /^Foo/?How to dereference a reference?