Jeff Thies wrote:

>   Anyone have any thoughts on subclassing AnyData for virtmaps?
> Virtmaps have two fields delimited by white space. 


You can just use AnyDatat's CSV format with space as a separator and 
trim set to 1 to eliminate the extra spaces:

$dbh->func('test','CSV',[<DATA>],{field_sep=>' ',trim=>1},'ad_import');


> I would think that for reading (SELECT) them you could pass in:
> field_sep,\s on the flags;
> 
> And for writing (INSERT):
> field_sep,\t on the flags;
> 
> I'm completely confused on how you would do an UPDATE.


Well, subclassing AnyData is alot simpler than you imagine.  All you 
need to supply is a read_field and write_field and AnyData will handle 
things like deleting, updating etc.  Here's an entire subclass that 
would handle all the same SQL as the other formats for what you describe:

package AnyData::Format::Vertmap
use AnyData::Format::Base;
use vars qw( @ISA $VERSION);
@AnyData::Format::Vertmap::ISA = qw( AnyData::Format::Base );

sub new {
     my $class = shift;
     my $self  = shift ||  {};
     return bless $self, $class;
}
sub read_fields {
     my $self = shift;
     my $str  = shift || return undef;
     my @fields = split /\s+/,$str;
}
sub write_fields {
     return join "\t",@_;
}
1;

That's all, stick in in your AnyData/Format directory and you can use it 
the same as Pipe, CSV, etc.

-- 
Jeff

Reply via email to