Great Circle Associates Majordomo-Users
(October 1993)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: questions for the group to answer...
From: Tim Irvin <irvin @ kerner . com>
Date: Thu, 30 Sep 1993 12:10:40 -0700
To: Kingsley Kerce <kerce @ dirac . scri . fsu . edu>
Cc: Majordomo-Users @ GreatCircle . COM
In-reply-to: Your message of "Thu, 30 Sep 1993 14:15:54 PDT." <199309301815.AA96858@dirac.scri.fsu.edu>

In message <199309301815.AA96858@dirac.scri.fsu.edu> you write:

> I ended up replacing the above code with:
> 
>      open(LS,"(cd $listdir; ls -1) |");
>  
>      while(<LS>) {
>  	$_ = &chop_nl($_);			# strip any trailing newline
> 
> followed by the while's body, finishing up with:
> 
>      close LS;
> 
> I'm taking this opportunity to ask if this is a reasonable solution to
> the problem, and if the problem was really a problem.  This is the
> first bit of Perl that I've ever written.

A better solution would be:

   opendir(DIR, $listdir);
   while (grep(!/^\.\.?$/, readdir(DIR))) {  # The grep removes "." and ".."
      <while body>
   }
   closedir(DIR);

Tim Irvin



Indexed By Date Previous: Re: questions for the group to answer...
From: Alan Millar <amillar@bolis.sf-bay.org>
Next: moderated lists
From: "Stephen Bannasch" <stephen_bannasch@terc.edu>
Indexed By Thread Previous: Re: questions for the group to answer...
From: Alan Millar <amillar@bolis.sf-bay.org>
Next: moderated lists
From: "Stephen Bannasch" <stephen_bannasch@terc.edu>

Google
 
Search Internet Search www.greatcircle.com