I noticed you were opposed to loops for some reason. I have a hard time imagining a good reason for a loopless stragegy. Here is how I would begin:

sub send_values { my ($args) = @_; my $values = "Your Results are:\n"; $values = join '', map { exists $args->{$_} ? $args->{$_} . "\n" : () } qw( name address pic id zip phone ); # do whatever it is you want to do with $values. }

You would still get an undefined value warning if the caller did something silly like: send_values( { name => undef } ); ...but that seems unlikely, and probably truly deserves a warning.

If your reason for avoiding loops has to do with performance, I recommend abandoning that concern for the time being.


Dave


In reply to Re: Subroutine question on use of uninitialized value. by davido
in thread Subroutine question on use of uninitialized value. by Anonymous Monk

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



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.