Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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,

Replies are listed 'Best First'.
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?
[1nickt]: Corion this looks good, from the pod: "there are 9000+ variations that are detected correctly in the test files (see t/data/* for most of them). If you can think of any that I do not cover, please let me know."
[TCLion]: some moron put the date like this : Mon Feb 20 09:31:30 2017
[Corion]: 1nickt: Yes, the module sounds promising indeed
[1nickt]: "putting the date in correct order" how?
[Corion]: TCLion: Whee ;)
[TCLion]: need to put like this : 2017-02-20 09:30:53
[1nickt]: That's why I asked if you are using DateTime. It has a large number of supporting modules (the author likes the term 'eco-system') so if you are already creating a DateTime obj from your dates, this module would read in the mnoron-formatted 1s seamlessly
[TCLion]: when I put the date together it looks like : 2017-Feb-24 (month is the problem)
[1nickt]: good luck, then.
[TCLion]: looking at DateTime documentation in monastery now

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-03-23 14:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (288 votes). Check out past polls.