Weekly Perl Script [Issue 7]

Bill Jones bill at fccj.org
Fri Jul 16 16:47:28 CDT 1999


On the Jax.PM jacksonville-pm-list;
"Bill Jones" <bill at fccj.org> wrote -


Jax.PM  -  Weekly Perl Script [Issue 7]

In an effort to raise the Member responsiveness on this List,
this weeks script is a 'Question':

Can you answer the question on the last line below; based upon the code
which appears before it?

RULES:  Do not use any discussion threads found
in clp.mod/misc or or on the FWP list.


#!/usr/local/bin/perl -wT

use strict;
use diagnostics -verbose;

my $len = -1;

open WORDS, "words" or die "No words file: $!";

while (<WORDS>) {
 chomp;              # no newline...
            s/#.*//; # no comments...
           s/^\s+//; # no leading whitespace...
           s/\s+$//; # no trailing whitespace...
 next unless length; # anything to process?

 print "\nInside of $_, I found ";

 while (++$len <= length) {
      print substr($_, $len, 1)
          if (index("abcdefghijklmnopqrstuvwxyz",
                     substr($_ , $len, 1)) > -1);
  }

$len = -1;
}

# What did I find?
#
# I found yet another LONG way to split up
# words into individual characters...
#
# Not yet sure if that is good or bad...
#
# QUESTION:  I know I could do the same thing with split - How?
#    BONUS:  What's so 'funny' about the above script?


Post your answers to:

    jacksonville-pm-list at happyfunball.pm.org


PS - The 'words' file is normally at '/usr/dict/words' ...


Enjoy, and good luck!
-Sneex-  :]
____________________________________________________________________
Bill Jones * Data Security Specialist * http://jacksonville.pm.org/
FCCJ * 501 W State St * Jacksonville, FL 32202 * 1 (904) 632-3089
    __ __                      __ __         __
   / // /__ ____  ___  __ __  / // /__ _____/ /_____ ____
  / _  / _ `/ _ \/ _ \/ // / / _  / _ `/ __/  '_/ -_) __/
 /_//_/\_,_/ .__/ .__/\_, / /_//_/\_,_/\__/_/\_\\__/_/
          /_/  /_/   /___/
         Running LinuxPPC RedHat 5.0 (Hurricane)
       __ _                     http://www.linuxppc.org
      / /(_)_ __  _   ___  __   http://www.apache.org
     / / | | '_ \| | | \ \/ /   http://www.redhat.com
    / /__| | | | | |_| |>  <    http://www.perl.com
    \____/_|_| |_|\__,_/_/\_\   http://www.gimp.org


The Jacksonville Perl Monger's Group is operated by -
Bill -Sneex- Jones ( sneex at usa.net ),
to whom send all praises, complaints, or comments...




More information about the Jacksonville-pm mailing list