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

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Sure, here's my example: I process incoming form inputs, default variables, and a user's preferences stored in a database--all three--to determine the value of a variable. That variable is given its proper order of precedence. When the form is first loaded, the user has not even logged in, so the default value should be assigned. After login, the preference stored in the database should be assigned. But if, via the form, the user has selected a different value, now the form's own inputs value should be assigned. Something like this:

our $loggedin; our %form_inputs; our $usercolor = ''; our $default_color = "#880000"; &processFormInputs; #routine that populates %form_inputs with form fi +eld values &checklogin; #routine to validate user's login credentials if ($loggedin) { &queryUserPreferences; }; my $color = $form_inputs{color} || $user_color || $default_color;

Please ignore the "roughness" of the example--it's not my actual code and only meant to be illustrative of the variable assignment situation.

Obviously, the user's form inputs will not be initialized in the hash before the user has even logged in.

Blessings,

~Polyglot~


In reply to Re^3: Is this code correct by Polyglot
in thread Is this code correct by suvendra123

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found