script

How to embed data in your Perl program

Here's a sample Perl program that demonstrates how you can include (embed) data inside of your Perl program, right in there next to the source code.

This simple program takes the data after the special __END__ tag, and makes it available to your Perl source code.

#!/usr/bin/perl

while (<main::DATA>)
{
  print $_;
}

__END__
George Washington
Abraham Lincoln
John F. Kennedy

As you can see, you loop through the data with this line of code:

A Perl script to convert Nagios/Unix epoch time to a human readable format

I had to work with Nagios a lot this morning, in particular reading through the nagios.log log file. If you're ever read that log file, or looked at some other Linux/Unix log files, you've seen records that display the time in an epoch time format, which looks like this:

1219822177

If you can read the epoch time format and know the actual human readable date and time, you're a better person than I am (or you've been looking at Nagios, Linux, or Unix log files too long).

Syndicate content