Trying to write a perl script... haven't done it in a while

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Trying to write a perl script... haven't done it in a while

Post by Luke »

I am trying to write a perl script and I am really rusty. I can't recall what "-d" and "-f" does. For instance, I am looking at an example script that looks like this:

Code: Select all

use strict;
use File::Find;
 
my($Group, $Text) = @ARGV;
my $Spool = "/var/spool/news";  # or wherever your newsspool lives
$| = 1;             # so we can see it run
find(\&Kibo, "$Spool/$Group");
 
sub Kibo
{
    -d and print "$_\n";
    -f and /^\d+$/ or return;
    print "$_\r";
 
    open(ARTICLE, $_) or return;
    my @lines = ;
 
    for my $line (@lines)
    {
        $line =~ /$Text/o and print $line;
    }
}
 
I've seen this in other places as well, for instance in the Zend Framework's mod rewrite rules:

Code: Select all

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
EDIT: Does it mean "directory"? It does, doesn't it? lol I feel stupid now.
Post Reply