http://www.perlmonks.org?node_id=1001215


in reply to basic doubt

Athanasius has already clearly explained the OPed code as it stands.

However, the use of the variable name  $hash followed by the capture of the literal string  'server' suggests either we are not seeing the real code or the real code is seriously bent. It is hard to imagine a case in which capturing a literally defined string has any point.

A guess, given the variable name, is that the original intention was to deal with an actual hash element. Note the enclosing curly brackets rather than parentheses in this example, which I hope is self-explanatory:

>perl -wMstrict -le "my %hash = (server => 'Foobar'); ;; $_ = 'Foobar today'; ;; my $uname; if (/^$hash{server}/) { $uname = 'not recognized'; } ;; print qq{$_ $uname}; " Foobar today not recognized