- my ($input_file, $record_type, $match, $add_items, $batch_comment) = @_;
-
- open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
- my $marc_records = "";
- $/ = "\035";
- my $num_input_records = 0;
- while (<IN>) {
- s/^\s+//;
- s/\s+$//;
- next unless $_; # skip if record has only whitespace, as might occur
- # if file includes newlines between each MARC record
- $marc_records .= $_; # FIXME - this sort of string concatenation
- # is probably rather inefficient
- $num_input_records++;
+ my ( $params ) = @_; #Possible params are: format input_file record_type match add_items batch_comment encoding no_replace no_create item_action
+ my $format = $params->{format} // '';
+ my $record_type = $params->{record_type} // 'biblio';
+
+ my ( $errors, $marc_records );
+ if( $format eq 'ISO2709' ) {
+ ( $errors, $marc_records ) = C4::ImportBatch::RecordsFromISO2709File(
+ $params->{input_file}, $record_type, $params->{encoding} );
+ } elsif( $format eq 'MARCXML' ) {
+ ( $errors, $marc_records ) = C4::ImportBatch::RecordsFromMARCXMLFile(
+ $params->{input_file}, $params->{encoding} );