Tech Thought

Tech tips, hints, and general musings. PHP, Perl, Mysql, Javascript, AJAX, JSON, Linux, Mac OSX

Entries Tagged ‘Perl’

How-To: Read an Excel (.xls) file with Perl

I’ve been working on a data import recently that required me to pull in the contents of a folder full of excel documents, all with the same structure containing data that needed to be collated into a single file.  There really isn’t an easy way to read Excel (xls files) in PHP so I’ve reverted [...]

Comments (6)

How-To: Convert Epoch to Normal Time

If you want to covert from epoch (number of seconds since 1970) to a more human readable format, you can use this simple perl script: #!/usr/bin/perl $time = localtime($ARGV[0]); print “$time\n”; Save it as epoch.sh and make it executable, then simply issue the following command from the command line: $> ./epoch.sh 1211926097 Wed May 28 [...]

Leave a Comment

How-To Fix Perl Error: Can’t locate object method “new” via package “LWP::Protocol::https::Socket”

I came across the following error while trying to connect to an LDAP server over HTTPS using the Perl module SOAP::Lite: Can’t locate object method “new” via package “LWP::Protocol::https::Socket” The way to fix this problem is to install the Crypt::SSLeay module from CPAN. Hope that helps someone!

Comments (2)

How-To: Install GD on CentOS

Installing the GD library is easy on CentOS thanks to yum.  Simply type: yum install gd gd-devel php-gd And all your GD fun is installed and ready to go.  I was trying to install the Perl module GD::Graph and it wouldn’t compile, complaining: GD.xs:7:16: error: gd.h: No such file or directory After installing the GD-Devel [...]

Comments (6)

Installing Crypt::Blowfish on Windows from PPD

I have had a requirement to encrypt in Perl and decrypt in Php. As a result, I’ve been looking at ways to get this to work. There are a number of people who have managed to get this working using the Crypt::Blowfish module in perl and mcrypt_cbc function in Php. That’s great unless you are [...]

Comments (1)

“Foreach” style loop syntax for Perl, Php and Javascript

I am always forgetting the syntax for foreach() loops in javascript. They actually don’t exist (not in their Perl or Php form anyway) and they differ in that they iterate over all the properties of an object, not an array. You can get some unexpected results if you aren’t careful. In perl you do the [...]

Comments (2)