Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Perl Symbols

by johnrein55 (Novice)
on Aug 12, 2013 at 18:50 UTC ( #1049165=perlquestion: print w/ replies, xml ) Need Help??
johnrein55 has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I am having issue while understanding the following symbols in one of the Perl Script :

1. $myroom->{$room}->{r} 2. (/l: (.+)$/i) 3. $system = 0 ; $Proom = $1 ; $cDept = uc $2 ;

Thanks,

Comment on Perl Symbols
Download Code
Re: Perl Symbols
by davido (Archbishop) on Aug 12, 2013 at 19:03 UTC

    1. $myroom->{$room}->{r}: $myroom contains a hash reference. The "->" operator dereferences it. $room must contain a hash key. {$room} uses the key in $room to index into the anonymous hash referenced by $myroom. $myroom->{$room} contains another anonymous hash reference. {r} indexes into that 2nd level anonymous hash.
    2. (/l: (.+)$/i): This part: /l: (.+)$/i is a regular expression. It says to match "l: ", followed by one or more characters, excluding newline. Capture those. And this all must occur at the end of the string. Case insensitively.
    3. Assign the value of 0 to the variable $system. Assign the first value captured in a regexp to $Proom. Assign the second value captured in a regexp to $cDept, after "upper casing" it.

    Read the following: perlintro, perlretut, perlrequick, perlreftut, and uc.

    Update: I see you have 21 posts here to PerlMonks starting in June. So perhaps my interpretation of your question was more basic than what you were asking. If so, I apologize and request that you be more specific in your question. And if not, then please read the documents I linked to. :)


    Dave

      So perhaps my interpretation of your question was more basic than what you were asking.

      Looking that the OP's quite basic questions, probably not. ;-)

      Having said that, more specific details on the questions would certainly not harm.

      Thanks everyone for the help. I have one last query.
      push @{$myroom->{$room}->{dpt}},$exroom ; $myrooms->{$room}->{r} = $room ;

      I am trying to understand a script, so far it is good.

      Thanks,

        At this point we should be able to ask you, "Well, what do you suppose those lines do?" And if you're unable to at least take a stab at it yourself, it means you didn't follow earlier advice to read the documentation.

        At the command prompt type "perldoc -f push". Or (easier on the eyes): visit http://perldoc.perl.org and type in push.

        Now try "perldoc perlreftut", and then do the same for perldsc, perlref. Read them. Ask about the parts you don't understand.

        I'm not trying to be stubborn here, the questions in this thread are all indicators that you're trying to understand code without trying to understand the language the code is written in. We can tell you exactly what those lines are doing, but that would just be throwing good money after bad; someone's already written the documents, someone's already pointed you in their direction... I know that laziness is a virtue for Perl programmers (which is why the documentation was written in the first place), but asking others to read it and tell you what it says is false laziness -- it will be more work for you in the longrun if you have to ask each and every time.


        Dave

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2014-09-16 09:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (158 votes), past polls