jdporter's user image
User since: May 30, 2002 at 16:48 UTC
Last here: Feb 10, 2016 at 21:49 UTC (1 hour ago)
Experience: 24845
Level: Canon (20)
Writeups: 2997
User's localtime: Feb 10, 2016 at 17:53 EST
Scratchpad: View
Member of: holders of unholy power, pedagogues, pmdev, QandAEditors, SiteDocClan
For this user:Search nodes

Rooms in my treehouse:
Popular links on homenodes
Tutorials digest
Survey of POOP Modules
Some cb snippets
Restyling PerlMonks
Sitedoclet usage analysis
Scratchpads & Blogs:
pad for admin-related stuff
pad for pmdev-related stuff
pad for other stuff
User Posts
CPAN contribs

Some of my root (and root-like) posts you may find interesting:

PerlMonks for the Absolute Beginner
New Service: Thread Watcher
New Snippets Index
XY Problem
Where should I post Y?
jdporter's place in the name space
test of ancient magic
test this
Nodes 1 .. 1000
There is no Perl Illuminati
PerlMonks Memorial Garden

Also check out my Free Nodelet Hacks
Also check out  
(RFC) Arrays: A Tutorial/Reference
Tk Photo Slideshow, with scrolling and scaling
Simple Console Menuing System
Control and Query Win32 Services at the command line
Strategy Handles
Linked Lists With No Memory Leak
There's Only One Way To Do It
Read and write Windows "shortcut" links
Create and Pop Up Outlook Notes from Perl
IO::MultiHandle - Operate on multiple file handles as one
map-like hash iterator

Here are some links I keep handy in my Free Nodelet:

Free Nodelet Settings
User Settings
Display Settings
Nodelet Settings
log out
PerlMonks statistics
Message Inbox
last hour of cb
Full-Page Chat
Chatterbox statistics

Monks I've met in meatspace:

PerlMonks Quine:

perl -MLWP::Simple -e "getprint 'http://perlmonks.org/?node_id=170442; +displaytype=displaycode'"


Previously, I used this:

Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.
This is a line (my own translation) from the classic movie Metropolis. Incidentally, my homenode pic above is a frame cap from this movie as well.

In the movie, the building of the mega-city Metropolis is likened to the legendary tower of Babel. This was intended as a warning: Knowing the fate which befell Babel, the builders of the present age should take care to avoid the same sins, and thus the same fate. Specifically, the builders of Babel lacked "heart" (a spirit of compassion and a willingness to compromise), and this resulted in a cataclysmic conflict between management and labor.

Most languages are like StackOverflow: I have a question, I want the best answer.
Perl is like PerlMonks: I have a doubt, I want to read an interesting discussion about it that is likely to go on a tangent. q-:

tye, in Re: What is PerlMonks? (why Perl)

<input type=submit value="border-width=d" " />

Posts by jdporter
fft japh in Obfuscated code
1 direct reply — Read more / Contribute
by jdporter
on Apr 17, 2008 at 11:53

    Based on technique discussed in encode a string into a complicated-looking trigonometric function

    print chr(91.540 + 0.765*cos(0.251*$_) + 3.886*sin(0.251*$_) - 1.470*cos(0.503*$_) - 7.599*sin(0.503*$_) + 4.480*cos(0.754*$_) - 1.094*sin(0.754*$_) - 11.495*cos(1.005*$_) + 22.147*sin(1.005*$_) + 1.792*cos(1.257*$_) + 8.512*sin(1.257*$_) - 20.389*cos(1.508*$_) - 1.167*sin(1.508*$_) - 1.011*cos(1.759*$_) + 2.549*sin(1.759*$_) + 2.712*cos(2.011*$_) + 3.110*sin(2.011*$_) + 6.179*cos(2.262*$_) - 2.177*sin(2.262*$_) - 2.232*cos(2.513*$_) + 16.511*sin(2.513*$_) + 5.236*cos(2.765*$_) + 1.260*sin(2.765*$_) - 1.607*cos(3.016*$_) + 4.017*sin(3.016*$_) )for 0..24;

    Update: Small change, props to ambrus.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
Getopt::Long-based commandline argument replacement substitution expansion in Snippets Section
No replies — Read more | Post response
by jdporter
on Apr 05, 2008 at 22:25

Modifies @ARGV by replacing a certain option (with or without argument) with something else. Uses Getopt::Long.

In my application, which takes a list of filespecs on the commandline, I replace -tar foo.tar with /tmp/tar/* after having extracted foo.tar into /tmp/tar/:

option_replacement( "tar=s", sub { system "tar xf $_[1] -C $tmpdir"; " +$tmpdir/*" } );
The first arg is the sort of thing you pass as an option spec to Getopt::Long's GetOption().
The second arg is a sub ref, the interface of which is exactly the same as a sub you'd pass as an option handler to GetOption(), except that it returns the list of strings to insert into @ARGV.

Insert something like a hyperlink in a Tk Text widget in Snippets Section
1 direct reply — Read more / Contribute
by jdporter
on Feb 12, 2008 at 13:09
Given a Tk::Text widget, insert a string at the current insert location which is "active", i.e. when clicked, executes some function. Actually, the behavior of the "link" is defined by the caller in terms of Tk events. Clicking (<ButtonPress>) is merely one such possibility.
overwrite a file in Snippets Section
1 direct reply — Read more / Contribute
by jdporter
on Apr 25, 2007 at 18:04

This code shows how to completely overwrite the data of a file. (Actually, not sure if it will DWIM on sparse files.)

The technique is illustrated in a sample practical application: "securely" erase and delete a file. (Note: does not securely erase and delete a file.)

Tk Photo Slideshow, with scrolling and scaling in Code Catacombs
1 direct reply — Read more / Contribute
by jdporter
on Oct 18, 2006 at 13:47

This is meant primarily to illustrate how to load and display photo images in Perl-Tk. Secondarily, it shows how to scale images, how to put images into a scrolling window, and how to "drag" such a image.

Usage: slideshow.pl [DIRECTORY]

If no directory is specified, it uses the current directory.

Currently, it obtains a list of all jpeg files (specifically, files matching *.jpg) in the directory and shows them in slideshow. Use PageUp/PageDown, Left/Right, and Up/Down to go to the previous/next image in the list. The list circles around at both ends.

To drag the image (only possible when scrollbar(s) present), press down the main mouse button somewhere on the image, move the mouse, and let up the button.

Tie::Scalar::Substring in Code Catacombs
1 direct reply — Read more / Contribute
by jdporter
on Jul 16, 2005 at 16:18

See embedded pod.

This module was inspired by Array - Reading frame problem, and was written with the intent of solving that problem directly.

Understanding how this works is greatly aided by understanding substr.

Wham! in Perl Poetry
No replies — Read more | Post response
by jdporter
on Dec 16, 2004 at 11:20
    # since he asked... kill ALRM => $him; exit;
Adso.pl in Code Catacombs
7 direct replies — Read more / Contribute
by jdporter
on Aug 17, 2004 at 19:00
See embedded POD.
Statistics::SGT in Code Catacombs
No replies — Read more | Post response
by jdporter
on Aug 15, 2004 at 23:13
Statistics::SGT - Simple Good-Turing Frequency Estimator
use Statistics::SGT;
The function Statistics::SGT::sgt takes a set of ( int:frequency, int:frequency_of_frequency ) pairs, and applies the Simple Good-Turing technique for estimating the probabilities corresponding to the observed frequencies, and P.0, the joint probability of all unobserved species.

The input should consist of a list of array-refs, each of which contains two positive integers: an observed frequency, and the frequency of that frequency.

No checks are made for linearity; the routine simply assumes that the requirements for using the SGT estimator are met.

The output is a list of ( int:frequency, [0,1.0]:estimated_probability ) pairs. The set of frequencies is the same as in the input array, plus the addition of a ( 0, P.0 ) element.

See also: http://www.grsampson.net/RGoodTur.html
Read and write Windows "shortcut" links in Snippets Section
2 direct replies — Read more / Contribute
by jdporter
on Jun 06, 2003 at 16:48
We know that Windows "shortcuts" aren't really symbolic links; only Windows Explorer and certain other applications can make sense of them. Now your perl program can, too. This uses OLE to access the contents of a shortcut.