This compiles:
sub Foo::show { print 'Foo::show' }; my %class = ( name => 'Foo' ); print qq{ $class{name}->show; #};
This does not:
sub Foo::show { print 'Foo::show' }; my %class = ( 'name}' => 'Foo' ); print qq{ $class{'name}'}->show; #};
I discovered this little curiosity because some programmer is using curly braces with qq// in our code:
return qq{$options{title}};
Re:Documented behaviour
Ovid on 2004-03-08T22:55:56
I wasn't aware that it was documented until I saw your post on Perlmonks. "Find the end first" certainly clears that up.
Result:sub Foo::show { print 'Foo::show' };
my %class = ( 'name}' => 'Foo' );
print qq{ $class{'name\}'}->show; #};
Foo->show; #
Re:Escape it
bart on 2004-03-09T12:35:28
I forgot to add: escaping works for the single quoting q{} too.result:print q{ $class{'name\}'}->show; #};In this case, backslashes work as an escape character only for the closing delimiter, its pairing delimiter, and other backslashes.$class{'name}'}->show; #result:print q{\'\$\@\{\}\[\]\(\)\"\\};\'\$\@{}\[\]\(\)\"\