Robinson, Josh wrote:
> Hi there, just having a problem accessing a singular hash value. Check the
> prog:
>
> open(FILE, "I:\\itscript\\temp\\BBGPriceImport\.imp") or die"Input file
> didn't open";
>
> my @list;
> my @list2;
> my $i;
> my %hashy = %_;
> my $temp ='';
>
> @list = <FILE>;
>
> foreach $i (@list){
> ($list2[0], $list2[1], $list[2]) = split(/\s+/, $i, 3);
> $hashy{$list2[0]} = $list2[1];
> }
>
> print("Tell me the CUSIP you want to retrieve the ticker for\n");
> $temp = <STDIN>;
> chomp($temp);
> $temp = "\n" . $hashy{$temp}[1];
> print($temp);
> sleep 10;
>
>
> for whatever reason, I can see the value of $hashy{$temp}[1] in the komodo
> debugger but I can't get it to report on the command line. The assignment to
> $temp is a shot at a quick fix. Anybody have an idea as to the dumb move I'm
> making here?
That's because you there is no array there. Just a single level
normal hash. What are you trying to build in the hash ? And
why do you think it has array elements ?
Slight rewrite:
use strict;
my %hashy;
my $file = 'I:/itscript/temp/BBGPriceImport.imp';
open FILE, $file or die "Error opening input file '$file': $!\n";
my @list = <FILE>;
foreach (@list) {
my @list2 = split /\s+/, $_, 3;
$hashy{$list2[0]} = $list2[1];
}
print "Tell me the CUSIP you want to retrieve the ticker for\n";
my $temp = <STDIN>;
chomp $temp;
$temp = $hashy{$temp};
print $temp, "\n";
__END__
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_ Castle of Medieval Myth & Magic http://www.todbe.com/
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl