Perl (5)

HeartInternet Hostpay Error Logs Empty

Ok, so Heartinternet do some cool things, but they also do some stupidly annoying things too. Like when you are integrating hostpay, any glance at the error log will tell you nothing, because they are empty… Well. Extend shows the hostpay error logs empty. But they are not, hostpay just can’t open the log files […]

watch mysql queries as they happen

cunning bit of Perl, not to be used permanently, but very handy indeed for a quick look at what’s actually being queried… [code] tcpdump -i eth0 -s 0 -l -w – dst port 3306 | strings | perl -e ‘ while(<>) { chomp; next if /^[^ ]+[ ]*$/; if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) { if (defined $q) { print […]

word mangler

  • August 25, 2012
  • Perl

a little pointless really but fun nevertheless! the old “can you read this?” chesnut. we can still read even though the characters of each word are mixed up, as long at the first and last letters are in the right place, we can read… create a file called inputfile and add your text, then run […]

find & replace text in file(s)

  • August 25, 2012
  • Perl

find and replace text in a particular file [code]perl -pi -e ‘s!/replace/this/!/with/this/!g’ file.php[/code] find and replace text in all files [code]perl -pi -e ‘s!/replace/this/!/with/this/!g’ *[/code] backup each file just in case you ruin it! [code]perl -pi.bak -e ‘s!/replace/this/!/with/this/!g’ *[/code]

tangled up terminal output!?

ever cat a binary file and ended up with a terminal looking a complete corrupted mess? me too. perl to the rescue. again. [code language=”perl”]perl -e ‘print "x0f"'[/code] sorted.