File: synopsis.pl

package info (click to toggle)
libfinance-streamer-perl 1.10-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 76 kB
  • ctags: 15
  • sloc: perl: 414; makefile: 40
file content (37 lines) | stat: -rwxr-xr-x 723 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl -w
use strict;
use lib '../lib';

#
# This is the example in the SYNOPSIS of the Finance::Streamer documentation.
#

use Finance::Streamer;

my $user = 'USER1234';
my $pass = 'SF983JFDLKJSDFJL8342398KLSJF8329483LF';
my $symbols = 'JDSU+QCOM+AMAT+IBM';
my $fields = '0+1+2+3+4+8+9+21';

my $streamer = Finance::Streamer->new( user => $user,
					pass => $pass,
					symbols => $symbols,
					fields => $fields,
					);

my $sub = sub
{
	my (%all_data) = @_;

	foreach my $symbol (keys %all_data) {
		print "$symbol\n";
		my %data = %{$all_data{$symbol}};
		foreach my $data_part (keys %data) {
			print "\t$data_part","=",$data{$data_part},"\n";
		}
	}
};

$streamer->{sub_recv} = $sub;

$streamer->receive;