This section is now closed for posting code. Please use Cool Uses For Perl instead.

Code Categories
Audio Related ProgramsFTP stuffNT Admin
CGI ProgrammingFun StuffWin32 Stuff
Chatterbox ClientsGUI ProgrammingMiscellaneous
CryptographyHTML UtilityText Processing
Database ProgrammingUtility ScriptsNetworking Code
E-Mail ProgramsWeb StuffPerlMonks Related Scripts


New Code
ARC4
on Nov 29, 2008 at 07:04
2 replies by Oromis92
this is a very simple code to encode a file or a string by ARC4. I don't use modules. I'm a relatively perl newbie... so the code isn't perfect
How to call Assembly language routines from Perl
on Nov 25, 2008 at 19:17
1 reply by bitshiftleft
This article shows how to write and call assembly language routines from Perl. I am using ActiveStates version of Perl on Win32. I used Win32::API, but other External Call modules can be used. Unlike the VB trick of using a callback from an API call to execute asm code, the method here is more direct. If you want to explore Win32 memory with Perl here is one way to do it. Also it is another way to learn assembly langauge. This code could be made more robust with Windows memory access API: VirtualQuery(), VirtualProtect(),IsBadReadPtr(), rtlMoveMemory(), ... and so forth. Look after __END__ in code below to see my output of the program
Gtk2::StatusIcon Demo
on Nov 25, 2008 at 14:41
0 replies by zentara
I recently posted Gtk2 TrayIcon Demo, but it turns out that TrayIcon dosn't work on Win32, and is being phased out in favor of StatusIcon. So here basically is the same code, but using StatusIcon (which will accept most any image and auto-magically make an icon for you). This code is mostly used to demonstrate how to setup a nice right-click configuration window. The left click just tails the script itself.....you can make it do whatever you want.
Image and Text Watermarked Letters
on Nov 25, 2008 at 12:49
0 replies by zentara
Just a simple script to show how to add semi-transparent images and text to an image, or in this case a blank US letter sized paper.... ready to run off reams of copies. This particular example is for Perl. The Programming Republic of Perl stamp is base64encoded into the script.
Server to Server irc channels retranslator (xchat style)
on Nov 10, 2008 at 22:59
0 replies by motzi
You have to choose one source server to copy all talks from (OUT_SERVER in %cfg) and other server to paste (IN_SERVER in %cfg) all from source. Looks like some irc 'spy'.
See code's %cfg to understand it better.

You can use some commands on IN_CHANNEL:
!say bla # will say bla to OUT_CHANNEL
!me bla # action say on OUT_CHANNEL
!sayto nick bla # will say bla to nick on OUT_SERVER
!list # will list all OUT_CHANNEL users
!whois nick # whois nick on OUT_SERVER
!nick newnick # change nick on OUT_SERVER


* can transcode between various codepages
* use local IP addr

########### FIXED BUGS ###############
№01: '!sayto nick message' is delivering receiver's nick instead of message
402: elsif($_[0] =~ /^sayto\s+([^\s]+)\s+(.+)/i) 403: { -404: print $out_sock "PRIVMSG ",$1," :",$1,"\r\n"; +404: print $out_sock "PRIVMSG ",$1," :",$2,"\r\n";
№02: wrong color handling on external msg echos
397: elsif($_[0] =~ /^say\s+(.+)/i) 398: { 399: print $out_sock "PRIVMSG ",$cfg{OUT_CHAN}," :",$1,"\r\n"; -400: print $in_sock "PRIVMSG ",$cfg{IN_CHAN}," :",$color{'graylight'} +,"<",$color{'blue'},$cfg{OUT_NICK},$color{'graylight'},"> ",$clr,$1," +\r\n"; +400: print $in_sock "PRIVMSG ",$cfg{IN_CHAN}," :",$color{'graylight'} +,"<",$color{'blue'},$cfg{OUT_NICK},$color{'graylight'},">",$clr,' ',$ +1,"\r\n";
Convert SQL queries to XLS files
on Nov 06, 2008 at 09:00
2 replies by dpavlin
Wouldn't it be nice to have a CGI script which would convert bunch of SQL queries into XLS file on-the-fly? And while we are at it, have multiple reports, each in it's own directory?

If you are interested in history of changes you can see them in subversion repository.

col-uniq -- remove lines that match on selected column(s)
on Nov 05, 2008 at 18:51
2 replies by graff
This is like the standard unix "uniq" tool to remove lines from an input stream when they match the content of the preceding line, except that the determination of matching content can be limited to specific columns of flat-table data. There's an option to keep just the first matching line or just the last matching line. Note that if the input is not sorted with respect to the column(s) of interest, non-adjacent copies will not be removed (just like with unix "uniq"). (update: note that column delimiters are specifiable by a command-line option)

The code has been updated to avoid the possible "out of memory" condition cited by repellent in the initial reply below.

pmchat-2
on Nov 01, 2008 at 13:14
2 replies by samwyse

A text-mode client for the Chatterbox, revised from mr. nick's original version. Several features that were promised were apparently never implemented, and have been struck out in the list below. Consider them enhancement requests that I may or may not get around to.

Changes

  • Check for and fetch autoinstall updates from Perl Monks, rather than mr. nick's now-dead home page. (Note: This feature is configurable, but is turned off by default.)
  • User configurable options (inside pmchat) to
    • Show (or not) your XP when launched
    • Show (or not) who's logged on when launched
    • Show (or not) new nodes when launched
    • Change the URL to check for updates

Main features:

  • Colorized output via ANSI escape sequences (*unix only)
  • Compatible with both *nix and Win32 (mostly barely :)
  • Displays most recent New Nodes
  • Can launch a browser to view a node
  • Check for and autoinstall updates
  • An "Away" mode for not being in "Other Users"
  • Uses the various XML Generators of PerlMonks
  • Tracks XP status
  • Tracks Reputation of your nodes (and displays WHICH nodes have changed -- and by how much)
  • Can launch a browser to view a node
  • Requires NO configuration, just download and run!
  • User configurable options (inside pmchat) for
    • Time-stamping each message (for long-term running) Broken, don't use this.
    • Turn off/on colorization (*unix only)
    • Which browser to use for node viewing
    • Check for and install code updates on launch
    • Seconds between polls for new messages (n/a on Windows)
    • Debugging mode. No output is sent to Perlmonks
    • Log file. Keeps a log of all messages. Set "logfile" to the desired filename. To stop, set "logfile" to "0" or "none".

Shortcomings (because this is a text-mode client):

  • Doesn't render HTML tags
  • Doesn't render special HTML entities (eg: &)
Gtk2 TrayIcon Demo
on Oct 28, 2008 at 14:17
0 replies by zentara
UPDATE Oct 29, 2008 I just found out that the separate module TrayIcon is not crossplatform ( not work on win32), and I should have used StatusIcon( a part of Gtk2 ) instead. I will try to update this as soon as I can to using StatusIcon. Sorry for any inconvenience.

This is a little demo to show some tricks to make a nice Gtk2::TrayIcon based app. It does nothing but tail itself, but includes a generic outline for including multi-colored icons, flashing the icon, and a configuration setup which you can easily modify.

A left click on the icon will popup a window tailling $0. This can be useful if you want to tail /var/log/messages( with correct permissions), etc, or if you want to setup an IO::Notify type watch on a directory. A directory and file selector option are in the configuration window. I may put the output of Sys::Info into a table as a real use.

A middle click will start the icon blinking, a second middle-click stops it. This just demos how to make your trayicon flash efficiently.

A right-click brings up the menu. It is full of easily modifiable code, to allow you to do what you want. All the checkbuttons do is change icon color, but you can make them do whatever you want.

I originally started to write a TrayIcon app, similar to Gufw a PyGtk2 TrayIcon app to monitor a firewall, but decided to write a generic one first.

After configuration, if you hit the "accept" button, it will save the options to __DATA__ for the next startup.

svn tk diff
on Oct 25, 2008 at 06:36
1 reply by casiano
I use "svn" command line for most of my work, but I very much like graphic diff over "svn diff". This program uses "svn export" to get a temporary copy of the file and then "tkdiff" or whatever program you specify to present the differences between your working copy and the one in the repository