2024 π Daylatest newsbuy art
And whatever I do will become forever what I've done.Wislawa Szymborskadon't rehearsemore 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
#11
Fall 1998
vol 3
num 3
The Birth of a One-Liner
A beginner's look at shrinking Perl code.
Just the FAQs: Suffering From Buffering
Your output doesn't always appear when you think it does.
Parsing VRML
Using Perl to interpret the Virtual Reality Modeling Language.
Source Filters
Ever wanted to encrypt your Perl programs?
A Web Proxy Module For mod_perl
Eliminate ads from your web pages with a proxy.
Perl Style
How readable is your code?
Perl News
What's new in the Perl community.
Win32: PerlCOM And PerlCtrl
Two new products for gluing Win32 COM objects.
Benchmarking
Measuring the speed of Perl programs.
Iterating Over Permutations
Making certain brute force searches a little more tractable.
Creating Applications With mod_perl
Using Apache::Registry, Apache::Sandwich, Embperl, and DBI.
Making Life And Death Decisions With Perl
Probability theory and deadly diseases.
Netscape and LDAP
Accessing directories via the Lightweight Directory Access Protocol.
The Third Annual Obfuscated Perl Contest Victors
perl -e '$# = print "1 + 1 = "; print 2'
The Perl Journal One-Liners
(1998) The Perl Journal One-Liners. The Perl Journal, vol 3(3), issue #11, Fall 1998.

The Perl Journal One-Liners


TPJ One-Liner #13

Little-known facts about qr// (new with Perl 5.005): it has a magic print value, and it's an object of type Regexp.


% perl -le 'print "My regex: ", qr/^watch/i'
   My regex: (?i-xsm:^watch this)
   
$rob = qr/red/i;
if ($rob->match("Fred Flintstone")) {
    print "Got obj fred!\n";
}

sub Regexp::match {
    my $self = shift;
    my $arg = @_ ? shift : $_;
    return $arg =~ /$arg/;
}

Courtesy of Tom Christiansen

TPJ One-Liner #14

Transpose a two-dimensional array:


@matrix_t = map{my$x=$_;[map {$matrix[$_][$x]}
                     0..$#matrix]}0..$#{$matrix[0]};

Courtesy of Tuomas J. Lukka

TPJ One-Liner #15

TPJ One-Liner #15


use PDL; use PDL::Graphics::TriD; $s=40;$a=zeroes
2*$s,$s/2;$t=$a->xlinvals(0,6.284);$u=$a->ylinvals
(0,6.284);$o=5;$i=1;$v=$o-$o/2*sin(3*$t)+$i*sin$u;
imag3d([$v*sin$t,$v*cos$t,$i*cos($u)+$o*sin(3*$t)]);

Courtesy of Tuomas J. Lukka

TPJ One-Liner #16

This code converts any GIF to an HTML table--each cell of the table corresponds to a pixel of the image. Use this to make your web advertisements seem like important content and circumvent Lincoln's Apache::AdBlocker. :


This code is online at https://tpj.com/tpj/one-liners.
use GD;$f='#ffffff';$T=table;sub p{print @_}
p"<body bgcolor=$f>";for(@ARGV){open*G,$_ or(warn("$_:
$!")&&next);$g=GD::Image->newFromGif(G)||(warn$_,
": GD error"and next);@c=map{$_!=$g->transparent
?sprintf'#'.('%.2x'x3),$g->rgb($_):$f}0..
$g->colorsTotal;p"<$T border=0 cellpadding=0
cellspacing=0>";($x,$y)=$g->getBounds;for$j(0..$y)
{p"<tr>";for($i=0;$i<$x;$i++){$s=1;$s++&&$i++while($i+1
<$x&&$g->getPixel($i+1,$j)==$g->getPixel($i,$j));p"
<td bgcolor=",$c[$g->getPixel($i,$j)],"
colspan=$s>&nbsp"}}p"</$T>"}

Courtesy of Mike Fletcher

TPJ One-Liner #17

Ever wish backquotes didn't interpolate variables? qx() is a synonym for backquotes, but if you use single quotes as a delimiter, it won't interpolate: qx'echo $HOME' works.

Courtesy of Tom Christiansen

TPJ One-Liner #18

"Use m//g when you know what you want to keep, and split() when you know what you want to throw away."

Courtesy of Randal L. Schwartz

TPJ One-Liner #19

Count the lines of pod and code in a Perl program:


@a=(0,0);while(<>){++$a[not m/
^=\w+/s .. m/^=cut/s]} printf"%d
pod lines, %d code lines\n",@a;

Courtesy Sean M. Burke

TPJ One-Liner #20

Results of the SunWorld reader survey (4,106 respondents)

Which of the following open source products do you have installed for WORK use?


Perl               83%
Sendmail           74%
Apache             72%
Linux              64%
Tcl                52%
Python             24%

Which of the following open source products do you have installed for PERSONAL use?

Perl               79%
Linux              77%
Apache             63%
Sendmail           61%
Tcl                55%
Python             34%
Martin Krzywinski | contact | Canada's Michael Smith Genome Sciences CentreBC Cancer Research CenterBC CancerPHSA
Google whack “vicissitudinal corporealization”
{ 10.9.234.151 }