Perl Programming Question: Download Perl Programming PDF

Does Perl have reference type?

Tweet Share WhatsApp

Answers:

Answer #1Yes. 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 #2Yes.
EX:
##need backslash to the operator
my $var = 6767;
my $ref = $var;
print "The reference of $var is $ref";

Download Perl Programming PDF Read All 46 Perl Programming Questions
Previous QuestionNext Question
What is the difference between /^Foo/s and /^Foo/?How to dereference a reference?