@@ -, +, @@ file uploads For this test, it doesn't matter that these barcodes aren't cataloged in your system. individually. --- tools/inventory.pl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/tools/inventory.pl +++ a/tools/inventory.pl @@ -21,6 +21,8 @@ use strict; use warnings; +use File::Slurp qw(read_file); + #need to open cgi and get the fh before anything else opens a new cgi context (see C4::Auth) use CGI; my $input = CGI->new; @@ -147,8 +149,12 @@ if ($uploadbarcodes && length($uploadbarcodes)>0){ my $qwthdrawn = $dbh->prepare($strsth); my @errorloop; my $count=0; - while (my $barcode=<$uploadbarcodes>){ - $barcode =~ s/\r?\n$//; + + # This allows us to handle files where lines are delimited by \r, \n, or \r\n. + my $file_contents = read_file( $uploadbarcodes ); + my @barcodes = split( /\r\n|\n|\r/, $file_contents ); + + for my $barcode ( @barcodes ){ if ($qwthdrawn->execute($barcode) &&$qwthdrawn->rows){ push @errorloop, {'barcode'=>$barcode,'ERR_WTHDRAWN'=>1}; }else{ --