2024 π Daylatest newsbuy art
Trance opera—Spente le Stellebe dramaticmore quotes
very clickable
data + munging

The Perl Journal

Volumes 1–6 (1996–2002)

Code tarballs available for issues 1–21.

I reformatted the CD-ROM contents. Some things may still be a little wonky — oh, why hello there <FONT> tag. Syntax highlighting is iffy. Please report any glaring issues.

The Perl Journal
#15
Fall 1999
vol 4
num 3
Letters
MIDI::Simple, and a little hate mail.
Perl News
What's new in the Perl community.
Just the FAQs: Precedence Problems
There's more to it than what you learned in fourth grade.
Braille Contractions and Regular Expressions
How a 14 kilobyte regex helps the visually challenged.
Client-Server Applications
Turn your program into a server.
Genetic Algorithms with Perl
Evolving algebraic expressions.
Review: Perl 5 For Dummies
Threadsafing a Module
Make your unthreaded modules palatable to threaded Perl.
Visual Debugging with ptkdb
Free software that finds bugs in your programs.
Predicting Sports Championships
Why the Denver Broncos will win the Superbowl again.
Hiding Object Data Using Closures
Concealing attributes from prying programmers.
Turning a Perl Program Into an NT Service
Long-lived Perl programs on Windows NT.
Operator Overloading in Perl
Use +, x, and other operators on your objects.
A Web Spider...In One Line?
Using HTML::, LWP::, and HTTP:: modules to traverse links.
Review: Writing Apache Modules with Perl and C
Prequel to SQL
Using Microsoft Access and DBI with a web application.
Version Control with makepatch
A free utility for updating documents.
The Obfuscated Perl Contest Victors
The Perl Journal One Liners
(1999) The Perl Journal One Liners. The Perl Journal, vol 4(3), issue #15, Fall 1999.

The Perl Journal One Liners


TPJ One-Liner #40

A name game.

s<^([bcdfghjklmnpqrstvwxyz]*)(\w+).*>
<$1$2 $1$2 $1o $1$2 / Bonana-Fanna-Fo-F$2 / 
Fe Fi Mo M$2 / $1$2!>i;

Courtesy Sean M. Burke

TPJ One-Liner #41

Extracting balanced parentheses from a string

use strict
              ;sub                  pars
            {my(                     $l,$r
          )=map{                       "\Q$_"
        }split//                        ,shift;
      my(@s,@r                            ,$i,$o,
     $v);for(                             split/([
    $l$r])/,                                shift){
    /$l/and                                $s[++$o]=
   ++$i;for                                $v(1..$o)#
   {$r[$v].=                              $_ if$s[$v]
    >0}/$r/and                            $s[(grep##
     $s[$_]==                            $i,0..$#s)
      [0]]=-$i         ,--$i<0&&        last;}($i=
        shift)?        wantarray       ?@r[grep
          -$s[$_       ]==$i,0..       $#s]:$r
            [$i]:      splice@r,      1;}$,
              ="\n"     ;print       pars
                 (@      ARGV       )#

pars('()', "(123 (456) (789) 0)") 

gives you the parenthesized substrings in order of appearance:
(123 (456) (789) 0),(456),(789)
pars('()', "(123 (456) (789) 0)", 2)

in a list context gives you list of substrings, opened on level 2:
(456),(789)

in scalar context gives you the second substring:
(456)

Courtesy Paul Clinger

TPJ One-Liner #42

Extract unique elements from a list given a key function

sub unique (&@) {
  my($c,%hash) = shift;
  grep { not $hash{&$c}++ } @_
}

@list = unique { $_       } @list;  
# Remove duplicate strings from @list.

@obj  = unique { $_->name } @obj;   
# Only include one object for 
# for each name.

Courtesy Don Schwarz

TPJ One-Liner #43

Seven "Magic Cards." Have a friend think of a number from 1 to 100. Give them cards one at a time and ask if their number is on the card. Mentally sum the first digits of each card with a "yes" answer. Go into trance, say the magic word "Ultrix!" and announce their number. Known to win bar bets.

for $a(0..6){$b=1;for $c(1..100){if($c&2**$a){printf
"%3d ",$c;print"\n"if!($b++%10)}}print"\n\n\n"}

Courtesy Bill Huston

Martin Krzywinski | contact | Canada's Michael Smith Genome Sciences CentreBC Cancer Research CenterBC CancerPHSA
Google whack “vicissitudinal corporealization”
{ 10.9.234.152 }