Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Perl Newbie

by Utilitarian (Vicar)
on Sep 18, 2014 at 13:46 UTC ( [id://1101052]=note: print w/replies, xml ) Need Help??


in reply to Perl Newbie

Welcome to the Monastery. Not sure how new a newbie you are... so I broke it down a bit
my # declare the variables in the local +scope (guarantees you won't overwrite a variable already in use or ca +pture a value already assigned) ($_configParam,$_paramValue) # A list of variable names that you a +re declaring, note that coma separated variables between parenthesis +are treated similarly to an array for assignment purposes = # and as you declare them you assign +them a value split( # a Perl function that splits strings + on the basis of a regular expression /\s*=\s*/ # the regular expression to use in th +e split. any number of space characters, followed by an equals sign f +ollowed by any number of space characters , $_ # The second part of the split state +ment, the string to be split $_ is the default variable, you will see + it a lot. , 2); # Limit the split to 2 values, close + the call to split and terminste the line with a semi-colon $configParamHash{$_configParam} # in an indexed list keyed on the par +ameter name = $_paramValue; # assign the value above to a hash en +try keyed on the parameter name
This is a common pattern used when reading through a configuration file to assign name value pairs in the file to an easily accessed indexed list.

print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Replies are listed 'Best First'.
Re^2: Perl Newbie
by MaKha (Initiate) on Sep 18, 2014 at 14:12 UTC

    I am a fairly new newbie. Your reply helped me understand the stuff. Many Thanks.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-18 02:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found