in reply to if statement doesnt work

Try and use some indentation first off, and make sure you're use-ing strict;

But it looks like you're saying the $input doesn't exist if you can't find it ONCE. If you have 10 files and you hit the first file and it doesn't match, are you going to say it doesn't exist?

What you might want is this:

use strict; ... my $found = 0; if ( $input ) { foreach my $image ( @files ) { # are you just looking to see if image CONTAINS input? if ( $image =~ /$input/ ) { $found = 1; last; } } } print "$input ".($found ? "found" : "not found")."\n";


HTH

Replies are listed 'Best First'.
Re^2: if statement doesnt work
by Anonymous Monk on Feb 14, 2005 at 19:27 UTC
    Yes..am checking if image contains input. Your solution works. thanks :)