Checking if file starts with X or Y

2001-10-15 Thread Chuck


I have this function:

sub getDIRcontents {
my $dir = shift;
my $dh = DirHandle-new($dir);
return sort
   grep {  }
   map   { $dir/$_ }
   grep  { !/^\./}
   $dh-read();
}


Where you see the XXX's in the line containig grep, I need a check for
this:

If the file starts with  REL or WinCIS. I tried egrep { ^WiNCIS|^REL } but
it did not work.


Any ideas.

-Chuck



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Checking if file starts with X or Y

2001-10-15 Thread _brian_d_foy

In article 012301c155a0$8ada3890$[EMAIL PROTECTED], 
[EMAIL PROTECTED] (Chuck) wrote:

 my $dh = DirHandle-new($dir);
 return sort
grep {  }
map   { $dir/$_ }
grep  { !/^\./}
$dh-read();

 Where you see the XXX's in the line containig grep, I need a check for
 this:

 If the file starts with  REL or WinCIS. I tried egrep { ^WiNCIS|^REL } but
 it did not work.

why not check for that in the first grep? note that you only have
to sort the filenames though ;)

return
map { $dir/$_ }
sort
grep { /^(?:WiNCIS|REL)/ }
$dh-read();
-- 
brian d foy [EMAIL PROTECTED] - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]