Monthly Archives: June 2009

Removing leading whitespace in file with perl.

Do you ever have code with such poor formatting that you just need to start over? This will let you remove all leading whitespace from every line in the file. I’ve found it handy every now and then. perl -i -pe’s/^\s+//’ file.c

Posted in Programming, Webhosting | Tagged , , | Leave a comment

Resolve IP address from hostname with perl.

Here is a small section of perl code that I stumbled upon that resolves an IP from a supplied hostname. Written by detour@metalshell.com. use Socket; use strict;   sub hostname { my (@bytes, @octets, $packedaddr, $raw_addr, $host_name, $ip); if($_[0] =~ /[a-zA-Z]/g) { $raw_addr = (gethostbyname($_[0]))[4]; @octets = unpack("C4", $raw_addr); $host_name = join(".", @octets); } else [...]

Posted in Programming, Webhosting | Tagged , | Leave a comment

Almost any connection string you’ll ever need.

I found a great source for templates for connection strings for all types of databases. Maybe I’m the only one that never knew about this place: www.connectionstrings.com.

Posted in Webhosting | Tagged | Leave a comment