Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




  • BioScripts
  • Jit
  • Perl script to count the number of files in a directory with regex

Perl script to count the number of files in a directory with regex

  • Public
By Jit 2444 days ago
#!/usr/bin/perl use strict; use warnings; my @allNames=("_D14_","_B14_","_B15_","_C1T1_","_C3T3_","_D12_","_D13_","_E1B1_","_E1B3_","_H001_","_H3-03_","_H3-04_","_HB0_","_C28_","_C33_","_C31_","_C1T2_","_D11_","_E11_","_E31_","_B11_","_B33_","_B3B1_","_C210_","_C211_","_C21_","_C24_","_C27_","_E2B2_","_H004_","_H4-28_","_Hprim34_","_Hprim53_","_HPRIM1_","_HPRIM21_","_HPRIM22_","_HPRIM36_","_A110_","_A12_","_A11_","_A111_","_A112_","_A13_","_A14_","_A15_","_A18_","_A19_","_C29_","_Hprim18_","_D22_","_D23_","_D21_","_A16_","_A17_","_B24_","_A3B1_","_C2B4_","_B22_","_H3-14_","_Hprim54_","_Hprim12_","_H4-02_","_H4-04_","_HPRIM15_","_HPRIM19_","_B39_","_C3B1_","_C3T1_","_HPRIM16_","_A21_","_A22_","_A32_","_A33_","_A24_","_A25_","_A23_","_B34_","_B38_","_E3B2_","_E3T1_","_HPRIM14_","_H158_"); my @files = glob("*.scf *.SCF"); foreach my $name (@allNames) { my $nName=lc ($name); my $cnt=0; foreach my $file (@files) { #print "$file =~ /$nName/\n"; my $nFile =lc $file; $cnt++ if ($nFile =~ /$nName/); #print "$file\n"; } print "$cnt\n"; if ($cnt > 2 or $cnt < 2) { print "$nName\n";} }