Re: using file globs and regex

Thanks Tad - works like a charm...

On Aug 7, 12:06 pm, Tad J McClellan <ta...@xxxxxxxxxxxxxx> wrote:
pgodfrin <pgodf...@xxxxxxxxx> wrote:
This program works fine (with file names f1..f8 in the directory):

use warnings;
use strict;
    print "$_";
        my $fn=$_;
        print "File name $fn found..." and exit;

But I was hoping to be able to do something like:
my $fn=grep (/f5/,<f*>);

Basically just trying to have less lines of code...any suggestions?

use grep() in a list context instead of in a scalar context.

I don't like using overloaded angle brackets in my code.

If I want equality, I use an operator that tests for equality.

    my($fn) = grep ( $_ eq 'f5' , glob 'f*');

Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"