Perl Programming Question: Download Questions PDF
Does Perl have reference type?
![Perl Programming Interview Answer Perl Programming Interview Question](https://globalguideline.com/public/images/interview/27.png)
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.
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";
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 Question | Next Question |
What is the difference between /^Foo/s and /^Foo/? | How to dereference a reference? |