| Store | Cart

Re: Parsing directory for particular filenames

From: Ian D. Stewart <i...@c-cor.com>
Thu, 22 Jun 2000 08:58:12 -0400
Cass...@epamail.epa.gov wrote:
> > Margaret, you wrote [in part]:> > opendir(WD,"C:/test/GraphList") || die "Cannot opendir . (Failed to open> directory): $!";> > foreach (sort readdir(WD))> >  {> >> > print qq|<a href="C:/test/GraphList/$_">$_</a><br>\n| unless /^\.\.?$/;> >   print qq!$filename\n!;> >  }> > closedir(WD) || die "Cannot closedir . (Failed to close directory): $!";> > Good so far, although I personally prefer 'or' instead of || in code> such as the above.  But you can move the test for the directories up> into the foreach, in the same way that you can make the test that you> actually asked about:

In the case above it doesn't make a difference, but 'or' and '||'
actually have different precedences.  Consider the two code snippets:

my $objref = Obj->new() or warn "unable to create object";

and

my $objref = Obj->new() || warn "unable to create object";


perldoc perlop for details.


Ian

-- 
99 little bugs in the code, 99 bugs in the code.
Fix one bug, compile again, 100 little bugs in the code.
100 little bugs in the code, 100 bugs in the code.
Fix one bug, compile again, 101 little bugs in the code...

Recent Messages in this Thread
Cass...@epamail.epa.gov Jun 21, 2000 09:18 pm
Ian D. Stewart Jun 22, 2000 12:58 pm
Messages in this thread