Convert a Perl Hash of Hashes into XML with XML::Dumper
For a project of mine, I wanted to convert a Perl data structure, a so called Hash of Hashes, into an XML.
The simple solution to this is to use the XML::Dumper module.
Read more…
For a project of mine, I wanted to convert a Perl data structure, a so called Hash of Hashes, into an XML.
The simple solution to this is to use the XML::Dumper module.
Read more…
Here’s a short script which I use to extract Cisco device-types from SNMP.
Bad enough, most of these devices return their device type ID differently, e.g. sometimes prefixed with an uppercase ‘C’, sometimes without any prefix, then again sometimes we find a suffix.
So here’s a snippet, that makes them look neat, so I can work with simple and unified looking device IDs.
Read more…
The ‘cat’ utility serves it’s purpose print the content of a file at once. So do ‘more’ and other tools as well. But they all do in ‘forward’ mode only.
To print a file in reverse order, at least some linux distros come with the ‘tac’ command, which will do a ‘reverse cat’.
But what to do, if ‘tac’ is missing?
Read more…
When writing shell scripts (bash, sh, etc) maybe you had to work with POSIX/UNIX timestamps from time to time.
While the serialized nature of the timestamp is great to work with for scripting, it’s easier for human beings to have them printed in date format.
Before you start digging around using some fancy conversion in Perl, check out the ‘date’ command first.
Read more…
Today a colleague of mine faced a very weird problem.
While parsing XML output from an HP ILO into Perl, his code constantly broke with the message:
FILE.XML:123 parser error : PCDATA invalid Char value 1
While the message itself states clearly that there is an unexpected character value (Char value 1, ASCII SOH) on one hand, it doesn’t tell the character position on the other.
Read more…
One might asume building a port from source should be fast and straight forward.
Not in this case, however…
Read more…
Well, today I just did not believe my eyes.
I was just bringing up a new webmail host when I noticed Apache throwing an 500 internal server error at me.
Read more…
Imagine you have a directory with thousands of text files, each of which containing some keywords to be replaced.
While there’s a lot of tools out there allowing you to find and replace strings in text files, there’s always a goog reason to use the tools that you already have.
The following snippet uses find in combination with perl to achieve the task:
Read more…
When I was setting up a development box today I encountered a strange error while compiling the Mail::ClamAV perl module.
Read more…