perl - Ignoring directories with glob -
i have code parses directory files hold hostname of various devices. want glob ignore directories of depth possible? instance have
@files = glob('/tftpboot/configs/*/*');
my folder architecture looks like
/tftpboot/configs/core/router1 (where router1 file) /tftpboot/configs/test/router2 (where router2 file) /tftpboot/configs/test/firewall/context (context file)
i want files router1, router2 , file of similar depth. ignore context any file of depth. suggestions?
thank you
follow with:
@files = grep { !-d $_ } @files; -or- @files = grep { -f $_ } @files;
you use file::find::rule.
my @files = file::find::rule->file->in('/tftpboot/configs');
Comments
Post a Comment