Hello,
I keep gettin this error!! and its sooooooooo annoying that I'm about to take off warnings!
view_quote.pl: Use of uninitialized value in string ne at C:\scripts\v
+iew_quote.pl line 147.
What Can I do to make it go away??
I'm using a module, Finance::Yahooquote that retrieves certain fields, one of them being the # of Float shares which can be 333,000,000 or 222,000,223,222. Either in the millions or the billions. The module stores this field using three or four array items.
My code looks like this:
use Finance::YahooQuote;
my @quotes = getcustomquote(["$symbol"], # using custom format
["Float Shares"]);
my $found=0;
foreach (@quotes) {
$found++;
if ($found > 1) { print "Only one stock symbol to view allowed."; die;
+ }
my $float;
if (${$_}[1] ne "") {
if (${$_}[4] ne "") { $float = "${$_}[1],${$_}[2],${$_}[3],${$
+_}[4]"; }
else { $float = "${$_}[1],${$_}[2],${$_}[3]"; }
} else { $float = "n/a"; }
print "$symbol Float Shares: $float";
}
unless ($found) { print "No quote info. for symbol: $symbol"; }
The error only pops up when the float shares falls in the million range. For example, if its only 200,000,000 --then the last array item ${$_}
4 is undefined and it gives me that error!! The line 147 points to the line where it has:
if (${$_}[4] ne "") { $float = "${$_}[1],${$_}[2],${$_}[3],${$
+_}[4]"; }
What can I do to make this error go away? How can I pre-define ${$_}
4 when I don't know the outcome of the number of the shares?
Thanks Monks!@
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.