rajsai28 has asked for the wisdom of the Perl Monks concerning the following question:

I have some files in a directory as mentioned below

CSEK.1.ABC19_KLJK_TT1.dat

CSEK.1.ABC19_AB_TT1.dat

Check_1.ABC19.dat.gz

CSEK.1.ABC19.dat

if ($file =~ m/^Check/) { print " File - 1 :=$file\n"; } elsif ($file =~ m/^CSEK.*TT1.dat$/) { print "File - 2 :=$file\n"; } elsif ($file =~ m/^CSEK.dat$/) { print "File - 3 :=$file\n"; }

output

File - 1 := Check_1.ABC19.dat.gz File - 2 := File - 3 := CSEK.1.ABC19_KLJK_TT1.dat CSEK.1.ABC19_AB_TT1.dat CSEK.1.ABC19.dat

How can i place more check before i read a file

I am expecting the output as below:

File - 1 := Check_1.ABC19.dat.gz File - 2 := CSEK.1.ABC19_KLJK_TT1.dat CSEK.1.ABC19_AB_TT1.dat File - 3 := CSEK.1.ABC19.dat

Update

I did the below and now i am getting the answer

if ($file =~ m/^Check/) { print " File - 1 :=$file\n"; } elsif ($file =~ m/^CSEK|TT1.dat$/) { print "File - 2 :=$file\n"; } elsif ($file =~ m/^CSEK.dat$/) { print "File - 3 :=$file\n"; }

output

Replies are listed 'Best First'.
Re: How to Check the file names while reading from the array.
by Anonymous Monk on Jun 07, 2013 at 10:38 UTC