Search and Replace with Perl

# Sometimes you need to change something in a bunch of files at once.
# These are some command-line ways of doing that.

# For universal replacement (in all files down from the current directory):
find ./ -type f -exec perl -pi -e \'s/stringtofind/stringtoreplacewith/g\' {} ;

# To do all ".php"s, for example:
find ./ -type f -name *.php -exec perl -pi -e \'s/stringtofind/stringtoreplacewith/g\' {} ;

# To find/replace in just the present directory:
perl -pi -e \'s/stringtofind/stringtoreplacewith/g\

ftp with perl

#!/usr/bin/perl -w

# Yet another time when dependence on libraries bit me, I had to see if
# I could manage an ftp script using the core perl libraries, so I wasn\'t
# dependent on Net::FTP being present in the same form on the system.
# This is just my proof of concept, developed with telnet and the perl
# cookbook.

use IO::Socket;

$remote_host = "remotehost";
$remote_port = 21;
$user = "username";
$pass = "password";

$socket = IO::Socket::INET->new(PeerAddr => $remote_host,
                                PeerPort => $remote_port,
                                Proto    => "tcp",
                                Type     => SOCK_STREAM)
    or die "Couldn\'t connect to $remote_host:$remote_port : $@n";


$answer = < $socket>;
print "$answer";

print $socket "user $usern";
$answer = < $socket>;
print "$answer";

print $socket "pass $passn";
$answer = < $socket>;
print "$answer";


print $socket "pwdn";
$answer = < $socket>;
print "$answer";


print $socket "quitn";
$answer = < $socket>;
print "$answer";

# and terminate the connection when we\'re done

Reader Prodding and Booting Linux

Luke has, quite rightly, pointed out that I have been lax in my updating of this site. after my last flurry of activity adding pieces of the back-end I completely forgot to note them here. I’ve been adding capabilities like entry editing tools and per-article permalinks and stylesheet switching, but other than that my time has been severely limited by huge wodges of work for school. That, sadly, won’t calm down again before the end of the term. The real problem is that I want to blog lots of articles, but I don’t have Internet access in class, which is where I can multitask and write things for this site in parallel with class notes. I’ve been meaning to download sites into the cache, but I keep forgetting. We’ll see if I get that done soon.

A while back I read this article, which I find fascinating. It is a very intriguing idea for the laptop, since it boots up so much more often than the desktop. I haven’t had the time to look into it more, but I’d sure like to.