Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: basic doubt

by AnomalousMonk (Abbot)
on Oct 27, 2012 at 17:29 UTC ( #1001215=note: print w/ replies, xml ) Need Help??


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


Comment on Re: basic doubt
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001215]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2014-09-21 04:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls