in reply to Re^3: Win32::OLE::Variant Array
in thread Win32::OLE::Variant Array

Nice to see you're making progress.  Have you tried printing the values like I suggested in my other post? E.g., for the given data structure:

for my $e (@$bbData) { my $d = $e->[0]; print "date: $d->[0]\n"; # presuming it's a date... print "price: $d->[1]\n"; }

(where $bbData is the variable you dumped (which I suppose is the data structure being returned by BLPGetHistoricalData()))

It shouldn't be necessary to reverse engineer those "(my $o = 27138604)"s. The idea behind the dump was just to get an idea of the general structure of the data returned. From what you got, you can tell that the first element in every innermost array is a Win32::OLE::Variant object. In other words, if it's a scalar-type variant (like VT_DATE), you should be able to just print it, as if it were a string (the object is automagically being stringified).

Replies are listed 'Best First'.
get Bloomberg History Prices using PERL
by kevind0718 (Scribe) on Sep 07, 2007 at 19:30 UTC
    brilliant! your code worked perfect. got dates and prices.
    many thanks. here is the code so others do not have to suffer with VB

    use Data::Dumper; use Win32::OLE; use Win32::OLE::Variant; $blpData = Win32::OLE->new('Bloomberg.Data.1') or die "can NOT load t +he blpData" ; #print $blpData->Timeout . "\n"; $aSec = Variant(VT_BSTR, "IBM Equity"); #@tmpArray = ("PX_Last"); $aFields = Variant(VT_ARRAY|VT_BSTR, 1 ); $aFields->Put(0, "PX_Last"); $sDate = Variant(VT_DATE, "2007/08/01"); $eDate = Variant(VT_DATE, "2007/08/10"); $bbData = Variant(VT_EMPTY, 1); $bbData = $blpData->BLPGetHistoricalData($aSec, $aFields, $sDate, $e +Date); print "Error: " . Win32::OLE->LastError . "\n"; #print "Array Size: " , $bbData->Dim . "\n"; #print "Returned: " . $bbData->Get(0) . "\n"; # print Dumper $bbData; for my $e (@$bbData) { my $d = $e->[0]; print "date: $d->[0] " . " Price: $d->[1] \n" ; #foreach $tmp (@aDim) { # print $tmp # } print "end" ;
      Awesome ... saved me loads of time. I just replace "IBM Equity" with "VOD LN Equity" and worked a dream !