Re: [Arsperl-users] Parse arx file
Brought to you by:
jeffmurphy
|
From: Thilo S. <thi...@ap...> - 2007-11-13 20:02:29
|
Here's a subroutine that splits a line in ARX format to an array of
values. It works for the basic data types such as character, integer etc.
More complicated data like attachments, diary and currency would of
course need some further processing.
use Text::Balanced qw( extract_delimited );
sub splitArxLine {
my( $line ) = @_;
my @ret;
my $val;
print "--------------------\n";
while( length($line) ){
if( substr($line,0,1) eq '"' ){
( $val, $line ) = extract_delimited( $line, '"' );
last if defined($line) && !defined($val);
$val =~ s/^"//;
$val =~ s/"$//;
$val =~ s/\\\\/\\/g;
$val =~ s/\\r//g;
$val =~ s/\\n/\n/g;
$val =~ s/\\"/"/g;
print "<$val>\n";
}else{
$line =~ s/(\S+)//;
$val = $1;
}
push @ret, $val;
$line =~ s/\s*//;
}
return @ret;
}
Regards,
Thilo
Brad O'Hara wrote:
> Hi all,
>
> Anyone written a routine to parse a .arx file?
>
> Thanks,
> Brad
|