[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] Something like "grepfirst"
- To: fwp@technofile.org
- Subject: Re: [FWP] Something like "grepfirst"
- From: Salve J Nilsen <sjn@pvv.org> (by way of Vicki Brown)
- Date: Mon, 26 Jul 1999 16:26:41 -0700
In-Reply-To: <199907261209.IAA05697@astro.fccj.cc.fl.us>
Message-ID: <Pine.BSF.4.10.9907261604440.71391-100000@verden.pvv.ntnu.no>
Content-Type: TEXT/PLAIN; charset=US-ASCII
>From vlb@cfcl.com Mon Jul 26 15:58:19 1999
Suddenly, Bill Jones uttered:
> Roland Bauer <roland.bauer@fff.at>, wrote:
> > What is the shortest code for finding the first
> > existing directory in a path of directories?
>
>
> foreach (qw(dir0 dir1 /tmp)) { (-d) ? print "$_", last : next; }
>
> But I am not sure how to get two-for-one commands...
>
> Does anyone know?
How about
foreach (qw(dir0 dir1 /tmp /etc) {(print,last) if -d}
or
$ perl -le 'while($_=shift){last if -d}print' /bar /tmp /foo /usr
?
:)
- Salve J. Nilsen
--
#!/usr/local/bin/perl
$_ = 'Sometimes I have dreams, dreams where I wish my email address was
president@whitehouse.gov
but, alas - it is only...'; s/.*?ent/sjn/s; s/whi.*/pvv.org\n/s; print;
"Just say NO to the McQuary Limit!"
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe