[TAG] 2-cent Tip: Perl Search Directory Function

Ben Okopnik ben at linuxgazette.net
Wed Jun 11 15:24:05 MSD 2008


On Wed, Jun 11, 2008 at 12:33:36PM +0200, Ren? Pfeiffer wrote:
> On Jun 10, 2008 at 1938 -0400, Ben Okopnik appeared and said:
> > On Tue, Jun 10, 2008 at 09:23:19PM +0200, Ren? Pfeiffer wrote:
> > > [...]
> > > Reading manuals costs too much time! ;)
> > 
> > That's one of the reasons for using 'strict' and 'warnings'. You don't
> > have to read anything - they'll just scream at you if you do it wrong.
> > :)
> 
> That's why I love to talk to GCC and Intel's CC; they tell long stories
> at times. :)

If you tell Perl to 'use diagnostics;', it will too - in a very
grandmotherly fashion. "Look, I know it's not your fault; you weren't
*really* trying to do anything bad - but this awful thing just
happened..." Unlike 'use warnings' and 'use strict', though, 'use
diagnostics' should be removed before putting the code into production:
it slows things down. For me, the easiest way to use it is from the
command line; that way, there's nothing to remove.

``
perl -Mdiagnostics scriptname
''

> And believe it or not, this wasn't working as expected yesterday (or I
> was really tired). The "($uid == $uid{'lynx'})" part failed. Too bad the
> code I fiddled with is on my machine at home. I'll try again now with a
> different code, let's see.

I just tried it with '0600' as perms - some of the files I had in '/tmp'
had those - and it worked fine. Try stripping out some of the conditions
in the 'wanted' block and see what happens.


-- 
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *




More information about the TAG mailing list