<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.3790.418" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I'm not an expert Perl developer, but I may be able
to help you. Here's the way I've done it in the past:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----------------begin code
sample------------------</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>#!/usr/bin/perl -w</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>use strict;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>my $input_dir = '/path/to/files/'; #
directory to search</FONT></DIV>
<DIV><FONT face=Arial size=2>my $fileext =
'.lisa'; #
file extension to find</FONT></DIV>
<DIV><FONT face=Arial size=2>my $count =
0;
# files found counter</FONT></DIV>
<DIV><FONT face=Arial size=2>my %files =
();
# hash for file list</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2># open filehandle to read output from "ls"
command</FONT></DIV>
<DIV><FONT face=Arial size=2>open(INF,"ls $input_dir|") or
&error_msg("Cannot get directory listing for \'$input_dir\'. Error:
\'$!\'\n");<BR>while(<INF>)<BR>{<BR> chomp; # drop line
terminator<BR> if ($_ =~ m/$fileext$/) # match files ending in specified
file extension<BR> {<BR> $files{$count} = $_; # add
entry to hash</FONT></DIV>
<DIV><FONT face=Arial size=2>
$count++;
# increment file counter</FONT></DIV>
<DIV><FONT face=Arial size=2> }</FONT></DIV>
<DIV><FONT face=Arial size=2>close(INF); # drop
filehandle</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>exit(0);</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----------------end code
sample------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I hope this helps.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Tom</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=pankaj.rwth@gmail.com href="mailto:pankaj.rwth@gmail.com">Pankaj
Bhatia</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A
title=fedora-perl-devel-list@redhat.com
href="mailto:fedora-perl-devel-list@redhat.com">fedora-perl-devel-list@redhat.com</A>
</DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, November 23, 2005 9:59
AM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Question.</DIV>
<DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT
face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR></DIV>Hi,<BR>I am
a beginner perl developer. <BR>I am writing a script for pasing all files in a
directory with perticular suffix. <BR>I use File::Find but I want to avoid
searching in subdirectories. I tried to use File::Find::prune in "wanted"
function. bit it did not work. So I use a heck <BR>return unless
($File::Find::topdir eq $File::Find::dir); to avoid processing in sub
directories. but this is an inefficient way. I want to limit search only to
first directory level.<BR>Please let me know the efficient way to do it. and
any comments/modification on the code would also be
appriciated.<BR>Regards<BR>Pankaj <BR><BR>sub wanted {<BR>
## dir tree Depth = 1<BR> return unless ($File::Find::topdir
eq $File::Find::dir);<BR> $fileext=
".cgd";<BR> if ($_ =~ /$fileext$/) { # $_ contain file base
name.<BR>
# $ sign at end of pattern looks
for<BR>
# .lisa suffix<BR><BR> $files[$Count] =
"$File::Find::name";<BR>
$Count++;<BR> }<BR>}<BR><BR>
<P><FONT face=Arial size=2></FONT>
<HR>
<P></P>--<BR>Fedora-perl-devel-list mailing
list<BR>Fedora-perl-devel-list@redhat.com<BR>https://www.redhat.com/mailman/listinfo/fedora-perl-devel-list<BR></BLOCKQUOTE></BODY></HTML>