SPOPS::Import - Factory and parent for importing SPOPS objects
my $importer = SPOPS::Import->new( 'object' ); $importer->object_class( 'My::Object' ); $importer->fields( [ 'name', 'title', 'average' ] ); $importer->data( [ [ 'Steve', 'Carpenter', '160' ], [ 'Jim', 'Engineer', '178' ], [ 'Mario', 'Center', '201' ] ]); $importer->run;
This class is a factory class for creating importer objects. It is also the parent class for the importer objects.
read_file( $filename )
Reads a file from $filename, returning the content.
$filename
read_perl_file( $filename )
Reads a file from $filename, then does an eval on the content to get back a Perl data structure. (Normal string eval caveats apply.)
eval
Returns the Perl data structure.
read_fh( $filehandle )
Reads all (or remaining) information from $filehandle, returning the content.
$filehandle
raw_data_from_file( $filename )
Reads $filename as a Perl data structure and does perliminary checks to ensure it can be used in an import.
raw_data_from_fh( $filehandle )
Reads $filehandle as a Perl data structure and does perliminary checks to ensure it can be used in an import.
Subclasses should override the following methods.
run()
Runs the import and returns an arrayref of status entries, one for each record it tried to import.
Each status entry is an arrayref formatted:
[ status (boolean), record, message ]
If the import for this record was successful, the first (0) entry will be true and the third (2) entry will be undefined.
If the import for this record failed, the first (0) entry will be undefined and the third (2) entry will contain an error message.
Whether the import succeeds or fails, the second entry will contain the record we tried to import. The record is an arrayref, and if you want to map the values to fields just ask the importer object for its fields:
my $field_name = $importer->fields->[1]; foreach my $item ( @{ $status } ) { print "Value of $field_name: $item->[1][1]\n"; }
None known.
Nothing known.
SPOPS::Import
SPOPS::Manual::ImportExport
Class::Accessor
Class::Factory
Copyright (c) 2001-2002 intes.net, inc.. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
To install SPOPS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPOPS
CPAN shell
perl -MCPAN -e shell install SPOPS
For more information on module installation, please visit the detailed CPAN module installation guide.