How to check if a file exists on a remote server

There are circumstances where you want to test if a file exists somewhere on a remote Linux server (e.g., /var/run/test_daemon.pid), without logging in to the server interactively. For example, you may want your script to behave differently depending on whether or not a specific file exists on a remote server. In this tutorial, I will […]
Continue reading…

 

How to parse JSON string in Perl

If you need to parse a JSON-formatted string in Perl, you can use JSON Perl module. The JSON module contains JSON-specific decode/encode functions that convert a JSON string into a Perl data structure, and vice versa. Here is how to parse JSON string in Perl. First, install JSON Perl module from CPAN: $ sudo perl […]
Continue reading…

 

How to use high-resolution gettimeofday in Perl

In some cases, you may need to measure time in high-resolution, for example, microsecond resolution as provided by gettimeofday() system call. In order to use microsecond-resolution time in Perl, you can use Time::HiRes Perl module which provides gettimeofday() microsecond-resolution timer function. To install Time::HiRes on Linux, run the following. $ sudo perl -MCPAN -e ‘install […]
Continue reading…