Symbolic references:
$i = "foo";
$$i = 10; # Sets $foo to 10
${"i"} = 10; # Sets $foo to 10
&$i(); # Calls foo();
push (@$i, 10, 20); # Pushes 10,20 into @foo
Run-time expression evaluation:
while (defined($str = <STDIN>)) {
eval ($str);
print "Error: $@" if $@;
}
This is a tiny Perl shell, which reads standard input, treats $str as a small program, and puts the compilation and run-time errors in $@.
Dynamic substitutions. Use the /e flag for the s/// operator, to specify an expression instead of a pattern:
$l = "You owe me 400+100 dollars";
$l =~ s/(\d+)\+(\d+)/$1 + $2/e;
print $l; # prints "You own me 500 dollars"
Module and object method invocations (see also #20 and #21):
$modulename->foo(); # Calls foo() in the module indicated by
# $modulename