in reply to Perlish while loop

a bit tighter. Basename is probably better than the s,.*/,, as pointed out above.
while (<$fh>) { if (/^M/) #What is this ? { chomp; my $filename = $_; $filename s,.*/,,; #strip off leading path info $seen->{$filename}++ if( $filename =~ /pdf/ || $filename =~ /msi/) } } if (! exists $seen->{'people.pdf'} ) { print "People not found\n"; } if (! exists $seen->{'animal.pdf'} ) { print "animal not found\n"; } if (! exists $seen->{'setup.msi')) { print "MSI file not found\n"; } exit;

Replies are listed 'Best First'.
Re^2: Perlish while loop
by Sun751 (Beadle) on Jul 16, 2009 at 23:58 UTC
    Your Solution is another new thing for me but I am bit paranoid about using "$seen", as looking at your code you are using $seen as a hash. But while declaring if I define "seen" as
    my %seen
    That give me error but if I declare it as a $seen variable it works and that makes me confuse. Any Suggestion?Please. Cheers