in reply to Look for ~*/.netscape/ dirs

I think this would work better. Unfortunately, it doesn't use perl...

find ~/.netscape -name prefs.js -o -name liprefs.js -print

--
$Stalag99{"URL"}="http://stalag99.keenspace.com";

Replies are listed 'Best First'.
Re: Re: Look for ~*/.netscape/ dirs
by merlyn (Sage) on Apr 14, 2001 at 10:16 UTC
    You missed the star after the tilde (which doesn't really work) {grin}. My solution looks in all home directories. Yours looks only in your own.

    -- Randal L. Schwartz, Perl hacker

      From your snippet, I couldn't see if it actually did go through all the homes (getpwent's worthy, but still, where's the full search?)

      Of course, there's...

      open(IN,"</etc/passwd"); while(<IN>) { chomp; next unless(/^([^:]+):/); $names=`find ~$1/.netscape -name prefs.js -o -name liprefs.js -pri +nt`; @names=split /\n/, $names; push @files, @names; }

      --
      $Stalag99{"URL"}="http://stalag99.keenspace.com";

        Uh, getpwent returns all the info for all the users, and therefore all the homes.

        Yours fails on a system that is YP'ed, er, NIS'ed.

        -- Randal L. Schwartz, Perl hacker

        strredwolf:
        (getpwent's worthy, but still, where's the full search?)

        Basically, what happens is the grep tests each potential dir returned by its 2nd arg (the do block) to see if it's a directory. If it is, the entry ends up in @dirs...

        It took me ages to figure this out, so it's worthy of a repeat. :o)

        (Yes, it took 4 reads of perldoc -f grep to finally parse correctly.)

        --
        Me spell chucker work grate. Need grandma chicken.