use warnings; use strict; use diagnostics; # <------------------------- Important line here. my $x = "Mmm...donut, thought Homer"; $x =~ /^(Mmm|Yech)\.\.\.(donut|peas)/; # matches foreach my $expr (1..$#-) { print "Match $expr: '${$expr}' at position ($-[$expr],$+ [$expr])\n"; } #### Can't use string ("1") as a SCALAR ref while "strict refs" in use at mytest.pl line 11 (#1) (F) Only hard references are allowed by "strict refs". Symbolic references are disallowed. See perlref. Uncaught exception from user code: Can't use string ("1") as a SCALAR ref while "strict refs" in use at mytest.pl line 11. at mytest.pl line 11. #### $name = "foo"; $$name = 1; # Sets $foo ${$name} = 2; # Sets $foo ${$name x 2} = 3; # Sets $foofoo $name->[0] = 4; # Sets $foo[0] @$name = (); # Clears @foo &$name(); # Calls &foo() (as in Perl 4) $pack = "THAT"; ${"${pack}::$name"} = 5; # Sets $THAT::foo without eval #### use strict 'refs';