Weekly Perl Script

Bill Jones bill at fccj.org
Mon May 17 21:49:53 CDT 1999


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

Here is an 'early' installment of

"The Weekly Perl Script" series...

(To make up for the week I missed...)

Enjoy!
-Sneex-  :]
______________________________________________________________________
Bill Jones  Data Security Specialist  http://www.fccj.org/cgi/mail?dss
______________________________________________________________________
  We are the CLPM... Lower your standards and surrender your code...
  We will add your biological and technological distinctiveness to
  our own... Your thoughts will adapt to service us...
  ...Resistance is futile...

         Jacksonville Perl Mongers
         http://jacksonville.pm.org
         jax at jacksonville.pm.org


----------  An explanation and the Scripts:
Hi All :]

As a new benefit for the Jacksonville Perl Monger
membership (now at 4 :) I present the kick off of
the "Weekly Perl Script" series.

Each Week, around Saturday or Sunday, I will submit
to the list a Perl Script which does something useful,
but one which isn't too hard to follow along with and
can be modified to attend other tasks.

I will post a script to the Jax-PM listserv and
allow one week for the group to discuss it; after
the week has passed I will either post a follow-up,
one which will help describe the functioning of
the prior weeks post or we will move on to a
new script to discuss that week.  Fair enough?

BTW:  The 'other' members may post script and/or
questions here as well.  I'm not saying that
any of them will be answered - but together
I am sure we can discover a solution!


Here is this weeks offering for your review -
(Actually three (3) scripts, presented in the
 order I believe you should 'think' about them.)

# Script Number 1...
$_ = "Sneaker's Nest";
while (/([neaker])*/g) {
    print join(" : ", map { defined $_ ? $_ : "undef" }
                $`, $&, $', $+, $1, $2, $3), " ", $y++, "\n";
}

# NOTES:  Where -
#
# $` = the string preceding what was successfully matched...
# $& = the string successfully matched...
# $' = the string following what was successfully matched...
# $+ = the last bracket matched in the last successful search...
# $1...$9... = Contains matched subpatterns from corresponding
#  parentheses in the last successful match...


# Script Number 2...
$_ = "Sneaker's Nest";
while (/([Sneaker's Nest])/g) {
    print join(" : ", map { defined $_ ? $_ : "undef" }
                $`, $&, $', $+, $1, $2, $3), " ", $y++, "\n";
}

# NOTES:  Where -
#
# $` = the string preceding what was successfully matched...
# $& = the string successfully matched...
# $' = the string following what was successfully matched...
# $+ = the last bracket matched in the last successful search...
# $1...$9... = Contains matched subpatterns from corresponding
#  parentheses in the last successful match...


# Script Number 3...
$_ = "Just Another Perl Hacker";
while (/([$_])/g) {
    print join(".", map { defined $_ ? $_ : "." } $&), "\n";
}


# Script Number 4...
#!perl -w

$_ = "Just Another Perl Hacker";
while (/([$_])/g) {
    print join(" ", map { defined $_ ? $_ : "undef" }
      (' ' x length($`)), $&, (' ' x length($')), $+), "\n";
}


OK, OK; so there were four scripts...  :]

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