Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Only files starting with xxxx

by amitbhosale (Acolyte)
on Feb 14, 2008 at 09:04 UTC ( [id://667895]=note: print w/replies, xml ) Need Help??


in reply to Only files starting with xxxx

Hi,
Below mentioned script list's the files starting with "xxx"
#!/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); }
========o/p======
File /home/myprog/xxxabc is present in /home/myprog/ File /home/myprog/xxxpqr is present in /home/myprog/

Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://667895]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-26 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found