Shawn Wilson wrote: > > This is pretty much my first perl program, so please escuse me if there > are loads of errors, but i only get two reported to me which i can't > figure out, any help would be appreciated. > > #!/usr/bin/perl
You should enable warnings and strict while developing your program. use warnings; use strict; > use File::Find; > use File::Remove qw(remove); Is there a reason you don't use perl's built-in unlink() function to remove files? > use Image::Info; > use File::Scan; > > sub wanted; > > $file = $File::Find::name; > $dir = $File::Find::dir; Setting these variables here will have no effect inside the wanted sub, you need to do a typeglob copy for it to work. our ( $file, $dir ); *file = *File::Find::name; *dir = *File::Find::dir; > print "Where are the pictures/?"; > $indir = <STDIN>; You need to remove the newline from the end of the input for this to work. chomp( my $indir = <STDIN> ); > File::Find::find({\&wanted, '$indir'); ^ ^ ^ You have an opening brace there without a closing brace. The single quotes mean that the string will not be interpolated. File::Find::find( \&wanted, $indir ); > exit; > > sub wanted { > unless ($file =~ '/^.*\.jpg\z/s') { ^ ^^^ ^^ The underlined parts are not doing anything useful here. unless ( $file =~ /\.jpg\z/ ) { > remove $file; > } > else ({$file_ext, $width, $heigh, $color_type} = Image::Info(\&file)) { ^ ^ ^^^^^^ You need parens () there instead of braces {}. What type of argument is Image::Info() expecting because you haven't defined the 'file' sub anywhere. > if( ($width < 200 && $height < 400) || ($width < 400 && $height < 200) ) { > remove $file; > } > elseif ($file_ext ne {'bmp|jpg|png|tif') { Your first statement removes any files that don't have a '.jpg' extension so only files WITH that extension should get to this point. You have a left brace { with no matching right brace }. If you want to compare multiple values you need a separate expression for each one. elseif ( $file_ext ne 'bmp' and $file_ext ne 'jpg' and $file_ext ne 'png' and $file_ext ne 'tif' ) { > remove $file; > } > elseif ($color_type = ('Gray'|'GrayA') { You have a left paren ( with no matching right paren ). You are doing an assignment here which is ALWAYS true. > remove $file; > | > elseif {$scanres->scan($file) ) { > if( $scanres->suspicious) ( > print "$file looks like it has a virus, delete/? /(Y//N/)" > if <STDIN>=~ 'y|Y' remove $file; The correct syntax for an if modifier statement is: remove $file if <STDIN> =~ /y|Y/; > ) > ) > } > } > > the errors are as follows: > > syntax error at ./bigimg2.pl line 17, near "'$indir')" > syntax error at ./bigimg2.pl line 24, near "else (" > Execution of ./bigimg2.pl aborted due to compilation errors. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]