Is there something that's supposed to be in $_->[4] and it's missing, or it just doesn't have a value? That is, is there some bug besides the warning?

In cases where I know I might get undef values, I cheat a bit. Rather than make the code that comes after it do all sorts of backflips to test the values, I just make sure they all have a value before I use them. Since undef turns into the empty string for stringy things, I replace those values with the empty string.

my @array = map { defined $_ ? $_ : '' } @array[0..$last];

Notice that I use an array slice on the right hand side. You don't need to do it that way, but you need to go through all of the elements you think you should have, including trailing undef (or missing) elements on the end.

Alternately, you could pepper your code with a bunch of checks for defined(), but that can get in the way of whatever you are really trying to do.

Other than that, I think you can get rid of a lot of code. It looks like you only want that first thing in @quotes, so you can just grab the first thing and ignore the rest. If there isn't anything there, you can die() right away (so you don't need $found), and the rest is just joining the elements. You could use this basic (and untested) structure:

use Finance::YahooQuote; # only use the first anon. array returned my( $quote ) = getcustomquote([ $symbol ], ["Float Shares"]); # stop if we didn't get back something die "No quote info. for symbol: $symbol" unless ref $quote; my $float = $quote->[1] ne "" ? join( ",", @$quote ) : "n/a"; print "$symbol Float Shares: $float";

Good luck :)

--
brian d foy <brian@stonehenge.com>

In reply to Re: A confusing Use of uninitialized value by brian_d_foy
in thread A confusing 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.