Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

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

I just ran across the following bit of code in pudge's journal on use Perl;

I just used "&&=" for the first time in real code. I hadn't planned on it, but there it was:

my($cfg1, $cfg2, $VirtualUser) = @_; $VirtualUser &&= getCurrentVirtualUser();
If the flag is true, then get the current value for the virtualuser. Cool. It is weird when you have been using perl for so long but use some feature for the first time.

So $VirtualUser changes it's meaning from 'do I want the virtual user' to 'the virtual user is'.

This caught my eye because I recently wrote a procedure in which a certain variable was first a string, then an array reference, and then a hash reference. While in this case the variable always signified the same thing (a header, FWIW) and so is 'monosignant' the type changed not once but twice ( polytypic? :), I thought perhaps I'd ask what other people think of these things.

Are your variables invariably monosignant and monotypic? Why or why not?

On one hand I don't see why they should be (mono-*) if the flow of the code suggests otherwise. On the other hand, I don't expect my variables to change type and so I may get quite confused when someone starts dereferencing what I was sure was a plain string. On the gripping hand, if I pay attention I should notice when said string becomes a hash ref, shouldn't I?

I just can't decide whether this is a Good Thing(tm) or not.

Scott

P.S. What do you think of 'polysignant'? Anyone got a better word for what I mean?


In reply to Polysignant variables by scott

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 studying the Monastery: (4)
As of 2024-04-25 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found