Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Answer
16.1: Set the environment variable TZ by replacing its value in the %ENV hash. The value you need to set varies from
system to system and, at least on a Unix machine, you use the names of files
in /usr/share/zoneinfo. For the Pacific
time zone, some systems use PST8PDT.
After that, use exec to turn your perl process into the date command, which has the same environment as
the perl process. You’ve effectively
created a wrapper that sets up the environment then executes the desired
command:
#!/usr/bin/perl
use strict;
use warnings;
$ENV{TZ} = 'PST8PDT';
exec 'date';On a Mac OS X system, you have to use US/Pacific:
#!/usr/bin/perl
use strict;
use warnings;
$ENV{TZ} = 'US/Pacific';
exec 'date';