[Nolug] Perl of wisdom

From: michaelrflora_at_charter.net
Date: Fri, 13 Dec 2002 10:25:42 -0500
Message-ID: <244640-2200212513152542411@M2W046.mail2web.com>

Somebody posted a Perl contest or quiz a couple of days ago. Well, I
refrained from posting my answer because of the spoiler time limit that was
mentioned. I'm not a Perl pro, but my attempt is appended below. Anybody
got anything better?

M.R.F., from Perlington on the Perl River (no, not really)

#A program to read words from a dictionary and output all four-letter
#contiguous strings that are unique

open(INFILE,"questions.txt");
open(OUTFILE,">answers.txt");

$total = $false = 1;
$true = 0;
while($word = <INFILE>){

        if (length $word > 4) { #allow 1 extra for newline
                chop $word;
                $curword = $word;

                while(length $word >= 4) {
                        $fourchar = substr( $word,length($word) - 4,4);
                        if(index($longstring,$fourchar)<0){
                                $longstring =
join('',$longstring,$fourchar);
                                $answers[$total-1][0] = $curword;
                                $answers[$total-1][1] = $fourchar;
                                ++$total;
                        }
                        chop $word;
                }
        }
}
for ($i = 0; $i <$total; $i++){
        print OUTFILE $answers[$i][0],$answers[$i][1],"\n";
}

Original Message:
-----------------
From: usserylaw@bellsouth.net
Date: Thu, 12 Dec 2002 21:04:49 -0500
To: nolug@joeykelly.net
Subject: Re: [Nolug] reservations have been made

hmmm -- a "co-orker?" -- have the agents of mordor already penetrated
NOLUG? I fear the NOLUG fellowship may be broken!

Joey Kelly wrote:
> Hey all,
>
> Here's the deal:
>
> Thursday, December 19, 7:30 PM (regular bat time & channel)
>
> King Buffet
> 601 Veterans, Metairie
> in the old Ralph & Kakoo's building
> 837-4383, ask for Charles (manager)
>
> Cost: $11 + drink + tax ~= $13
>
> Buffet looks great, a cow-orker ate there last night, thinks it's pretty
good.

___________________
Nolug mailing list
nolug@nolug.org

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

___________________
Nolug mailing list
nolug@nolug.org
Received on 12/13/02

This archive was generated by hypermail 2.2.0 : 12/19/08 EST