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":