From e4b90465a807a3c9ef748dabf23b3a28d8259e7a Mon Sep 17 00:00:00 2001 From: Chris Nighswonger Date: Wed, 20 Feb 2008 16:52:26 +1300 Subject: [PATCH] Second fix for bug 1848 correcting bad conditional Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- tools/picture-upload.pl | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index f38e462055..b6fe1896b8 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -86,6 +86,7 @@ if ( $uploadfile ) { output_html_with_http_headers $input, $cookie, $template->output; sub handle_dir { + warn "Entering sub handle_dir" if $DEBUG; my ( $dir ) = @_; my ( %count ); my $file; @@ -93,30 +94,32 @@ sub handle_dir { opendir my $dirhandle, $dir; while ( my $filename = readdir $dirhandle ) { - $file = "$dir/$filename" if ($filename =~ qr/datalink\.txt/i || qr/idlink\.txt/i); + $file = "$dir/$filename" if ($filename =~ m/datalink\.txt/i || $filename =~ m/idlink\.txt/i); } unless (open (FILE, $file)) { - print "Openning $dir/$file failed!\n"; + warn "Opening $dir/$file failed!" if $DEBUG; return 0; }; while (my $line = ) { - chomp $line; - my ( $filename, $cardnumber ); - my $delim = ($line =~ /\t/) ? "\t" : ","; - ($cardnumber, $filename) = split $delim, $line; - $cardnumber =~ s/[\"\r\n]//g; # remove offensive characters - $filename =~ s/[\"\r\n\s]//g; - warn "Cardnumber: $cardnumber Filename: $filename" if $DEBUG; - - if ($cardnumber && $filename) { - warn "Source: $dir/$filename Target: $destdir/$cardnumber.jpg" if $DEBUG; - my $result = move ( "$dir/$filename", "$destdir/$cardnumber.jpg" ); - if ( $result ) { - $count{count}++; - push @{ $count{filenames} }, { source => $filename, dest => $cardnumber .".jpg" }; - } + warn "Reading contents of $file" if $DEBUG; + chomp $line; + warn "Examining line: $line" if $DEBUG; + my ( $filename, $cardnumber ); + my $delim = ($line =~ /\t/) ? "\t" : ","; + warn "Delimeter is \'$delim\'" if $DEBUG; + ($cardnumber, $filename) = split $delim, $line; + $cardnumber =~ s/[\"\r\n]//g; # remove offensive characters + $filename =~ s/[\"\r\n\s]//g; + warn "Cardnumber: $cardnumber Filename: $filename" if $DEBUG; + if ($cardnumber && $filename) { + warn "Source: $dir/$filename Target: $destdir/$cardnumber.jpg" if $DEBUG; + my $result = move ( "$dir/$filename", "$destdir/$cardnumber.jpg" ); + if ( $result ) { + $count{count}++; + push @{ $count{filenames} }, { source => $filename, dest => $cardnumber .".jpg" }; } + } } $count{source} = $dir; $count{dest} = $destdir; -- 2.39.5