unix - Get names of all the directories with similar naming pattern in Perl -


i have directory "logs" contains sub-directories "a1", "a2", "a3", "b1", "b2", "b3".

i want write perl code search sub directories name pattern "a", i.e. directories names starting character a.

please me.

use perl core module file::find:

use strict; use warnings; use file::find;  #find in 'logs' directory, assume script executed @ folder level  find(\&wanted, 'logs');  sub wanted {      #subroutine called every file / folder founded ($_ has name of current)     if(-d , /^a/ ) {        print $_, "\n";      } } 

update: if want parametrize prefix, can this:

use strict; use warnings; use file::find;  $prefix = 'b';  find(\&wanted, 'logs'); sub wanted {      if(-d , /^$prefix/ ) {        print $_, "\n";      } } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -