Hi Monks!
I am passing values to a subroutine and sometimes in my code I don't need to pass all the values expected by the sub, and I know I am getting an "Use of uninitialized value..." from the expected values in the subroutine. OK here is the passing sample code:
...
my $info = send_values(
{
name => $name,
address => $address,
id => $id,
pic => $pic,
}
);
...
Here is the sample sub code:
...
sub send_values{
my ($args) = @_;
#test:
my $values = "Your Results are:\n
$args->{name}\n
$args->{address}\n
$args->{pic}\n
$args->{id}\n
$args->{zip}\n
$args->{phone}\n
";
}
These two "$args->{zip} and $args->{phone}" will give me warnings on "use of uninitialized value" because I am not passing them. Can I use some sort of "if @_ defined" to prevent this issue?
Thanks for the help!
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.