Recently I saw this discussion on LinkedIn.
In there a guy asks whether modifying script while it's executing will change
the way it executes.
Continue reading Reloading of Perl script while it's running
Recently I saw this discussion on LinkedIn.
In there a guy asks whether modifying script while it's executing will change
the way it executes.
Continue reading Reloading of Perl script while it's running
Couple of days ago I had a problem that I couldn't solve after ~ 2 hours, and decided to ask on IRC. Almost immediately after asking, I figured out the solution, but David asked me to write about the solution, even though it's now (for me) completely obvious.
The problem was like this:
I had two tables, with very simple structure: event_when timestamptz, event_count int4, and wanted to show it as a single recordset with columns: event_when, event_count_a, event_count_b, but the problem was that event_when usually didn't match. Here is an example:
Just thought I'll share it – maybe somebody else will use it.
I'm using KDE 3.5, so the final “dcop …" command, simply sets the file as current wallpaper.
I also use 1680×1050 resolution – which you can probably guess from the code 🙂
#!/usr/bin/perl -w use strict; use English qw( -no_match_vars ); use WWW::Mechanize; my $agent = WWW::Mechanize->new(); $agent->get("http://interfacelift.com/wallpaper_beta/downloads/random/widescreen/1680x1050/"); exit unless 200 == $agent->res->code; my @links = $agent->find_all_links( 'url_regex' => qr{1680x1050.jpg}, ); exit if 0 == scalar @links; $agent->get( $links[ rand @links ] ); exit unless 200 == $agent->res->code; my $username = getpwuid( $REAL_USER_ID ); my $filename = '/tmp/interfacelift.' . $username . '.jpg'; open my $fh, '>', $filename or exit; binmode $fh; print $fh $agent->res->decoded_content; close $fh; $ENV{"DISPLAY"} = ':0'; system( qw( /usr/bin/dcop kdesktop KBackgroundIface setWallpaper ), $filename, 4 ); exit;
Pretty simplistic, but it does the job. Now, I add this line to my crontab:
*/5 * * * * /home/depesz/bin/interfacelift.pl
And enjoy new, nice wallpaper every 5 minutes 🙂