in reply to Only files starting with xxxx
Hi,
Below mentioned script list's the files starting with "xxx"
Below mentioned script list's the files starting with "xxx"
========o/p======#!/usr/bin/perl -w use strict; sub dodir { opendir(DIR,$_[0]) or die "Couldn't open $_[0] directory $!"; my $dir=$_[0]; if ( $dir !~ /\/$/ ) { $dir .= "/"; } my @List=readdir(DIR); closedir(DIR); splice(@List,0,2); foreach my $file (@List) { $file = $dir.$file; if( -d $file) { dodir($file); } elsif ($file =~ /xxx*/ ) { print "\n File $file is present in $di +r"; #print "\n File type: ",stat($file)->mode; } } } my $dir_name="/home"; if ( -d $dir_name) { dodir($dir_name); }
File /home/myprog/xxxabc is present in /home/myprog/ File /home/myprog/xxxpqr is present in /home/myprog/
Originally posted as a Categorized Answer.
In Section
Seekers of Perl Wisdom