N
niall.macpherson
I am using the outlook interface for the first time . I am attempting
to read a mail message which has a number of lines which should match
the pattern
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/
To test the pattern match I used the following test program
-------------------------------------------------------------------------------------------------------------
use strict;
use warnings;
use Data:umper;
my $bigstring = '';
while(<DATA>)
{
$bigstring .= $_;
}
print Dumper $bigstring;
while($bigstring =~
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/g)
{
my ($tablename, $date, $time, $ticks) = ($1, $2, $3, $4);
print Dumper $tablename, $date, $time, $ticks;
}
__END__
fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,
-------------------------------------------------------------------------------------------------------------------------
which produced the desired output
C:\develop\NiallPerlScripts>multimatch.pl
$VAR1 = 'fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'bondticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '361784391';
$VAR1 = 'ir_swapticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '241879716';
$VAR1 = 'intrateticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '232578257';
$VAR1 = 'fraticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '209225323';
$VAR1 = 'rtrspttick';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '205294165';
C:\develop\NiallPerlScripts>
-----------------------------------------------------------------------------------------------------------------------------------
However, when I incorporated this into my program which reads the data
from outlook as follows
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
use Data:umper;
my $outlook = Win32::OLE->new('Outlook.Application') or die
"Error!\n";
my $namespace = $outlook->GetNamespace("MAPI");
my $folder = $namespace->GetDefaultFolder(olFolderInbox);
my $items = $folder->Items;
my %tickstats;
for my $itemIndex (1..$items->Count)
{
my $message = $items->item($itemIndex);
next if not defined $message;
if($message->{Subject} =~ /Tick Status Test/)
{
print Dumper 'Body ' . $message->{Body};
while( $message->{Body} =~
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/g)
{
my ($tablename, $date, $time, $ticks) = ($1, $2, $3, $4);
print Dumper $tablename, $date, $time, $ticks;
$tickstats{ $tablename } { $date } = $ticks;
}
}
}
print Dumper \%tickstats;
exit(0);
--------------------------------------------------------------------------------------------------------------------------------
I ended up with an infinite loop - the first line just keeps getting
re-processed
C:\develop\NiallPerlScripts>outlook.pl
$VAR1 = 'Body fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,
';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
.....................................................................
....................................................................,.
ad infintum .......
I cannot see why - can anyone help ?
Thanks
to read a mail message which has a number of lines which should match
the pattern
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/
To test the pattern match I used the following test program
-------------------------------------------------------------------------------------------------------------
use strict;
use warnings;
use Data:umper;
my $bigstring = '';
while(<DATA>)
{
$bigstring .= $_;
}
print Dumper $bigstring;
while($bigstring =~
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/g)
{
my ($tablename, $date, $time, $ticks) = ($1, $2, $3, $4);
print Dumper $tablename, $date, $time, $ticks;
}
__END__
fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,
-------------------------------------------------------------------------------------------------------------------------
which produced the desired output
C:\develop\NiallPerlScripts>multimatch.pl
$VAR1 = 'fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'bondticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '361784391';
$VAR1 = 'ir_swapticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '241879716';
$VAR1 = 'intrateticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '232578257';
$VAR1 = 'fraticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '209225323';
$VAR1 = 'rtrspttick';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '205294165';
C:\develop\NiallPerlScripts>
-----------------------------------------------------------------------------------------------------------------------------------
However, when I incorporated this into my program which reads the data
from outlook as follows
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
use Data:umper;
my $outlook = Win32::OLE->new('Outlook.Application') or die
"Error!\n";
my $namespace = $outlook->GetNamespace("MAPI");
my $folder = $namespace->GetDefaultFolder(olFolderInbox);
my $items = $folder->Items;
my %tickstats;
for my $itemIndex (1..$items->Count)
{
my $message = $items->item($itemIndex);
next if not defined $message;
if($message->{Subject} =~ /Tick Status Test/)
{
print Dumper 'Body ' . $message->{Body};
while( $message->{Body} =~
/(.*),(\d\d\d\d-\d\d-\d\d),(\d\d:\d\d:\d\d),(\d*)/g)
{
my ($tablename, $date, $time, $ticks) = ($1, $2, $3, $4);
print Dumper $tablename, $date, $time, $ticks;
$tickstats{ $tablename } { $date } = $ticks;
}
}
}
print Dumper \%tickstats;
exit(0);
--------------------------------------------------------------------------------------------------------------------------------
I ended up with an infinite loop - the first line just keeps getting
re-processed
C:\develop\NiallPerlScripts>outlook.pl
$VAR1 = 'Body fxticks,2006-04-19,09:40:04,412130617,
bondticks,2006-04-19,09:40:04,361784391,
ir_swapticks,2006-04-19,09:40:04,241879716,
intrateticks,2006-04-19,09:40:04,232578257,
fraticks,2006-04-19,09:40:04,209225323,
rtrspttick,2006-04-19,09:40:04,205294165,
';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
$VAR1 = 'fxticks';
$VAR2 = '2006-04-19';
$VAR3 = '09:40:04';
$VAR4 = '412130617';
.....................................................................
....................................................................,.
ad infintum .......
I cannot see why - can anyone help ?
Thanks