# Circular References in Perl

PERLServer Side ProgrammingProgramming Scripts

A circular reference in Perl occurs when two references contain a reference to each other. You have to be careful while creating references otherwise a circular reference can lead to memory leaks. Following is an example −

## Example

Live Demo

#!/usr/bin/perl
my $foo = 100;$foo = \$foo; print "Value of foo is : ",$\$foo, "\n";

## Output

When the above program is executed, it produces the following result −

Value of foo is : REF(0x9aae38)
Published on 29-Nov-2019 07:19:21