GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SPOPS::Import(3) User Contributed Perl Documentation SPOPS::Import(3)

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.

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.)

Returns the Perl data structure.

read_fh( $filehandle )

Reads all (or remaining) information from $filehandle, returning the content.

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.

object_class

Class of the object to import

data

Data for this import. The implementation subclass specifies its format, but it is normally either an arrayref of arrayrefs or an arrayref of hashrefs.

extra_metadata

Placeholder for user-defined metadata.

Subclasses should override the following methods.

run()

Runs the import and, unless otherwise specified, 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, the second (1) will be the object inserted (if possible, otherwise it is the data structure as if the record failed), and the third (2) entry will be undefined.

If the import for this record failed, the first (0) entry will be undefined, the second (1) will be the data structure we tried to insert, 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];
 
 # On a success (if possible):
 
 foreach my $item ( @{ $status } ) {
     print "Value of $field_name: ", $item->[1]->$field_name(), "\n";
 }
 
 # On a failure (or success, if not possible):
 
 foreach my $item ( @{ $status } ) {
    print "Value of $field_name: $item->[1][1]\n";
 }

None known.

Import XML

We currently export XML documents but we do not import them. It would be useful to do this.

SPOPS::Manual::ImportExport

Class::Accessor

Class::Factory

Copyright (c) 2001-2004 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>
2004-06-02 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.