I find myself frequently being an advocate for non-obfuscated code - I think your original code
my $string = get_string();
put_string_ref(\$string);
is very simple and clear and easily understood. I'm sure some people will disagree with me here, but IMHO doing
put_string_ref(\get_string())
is at least somewhat obfuscated. It kind of begs the question "What am I passing to put_string_ref? Is it a reference to the get_string subroutine, or is it a reference to the string that get_string returns?". It is not absolutely clear looking at that code *what* is being passed to put_string_ref.
Again, just my opinion, but your original code is better since it is very clear about what it is doing - self documenting code is best. If you need to spend time figuring out what it does, then chances are it could have been written in a more understandable and more easily maintainable way.
HTH.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.