1

I need to run a Perl script, but make it think that it is in a different timezone (GMT) than the server is configured to use normally.

I would like to do this without modify the existing script, by means of some environment variables or any configuration settings if possible.

This is for OS X and its vendor Perl (v5.12.4).

Thilo
  • 240
  • 1
  • 2
  • 9

1 Answers1

6

You can use the TZ environment variable ($ENV{TZ}). See https://stackoverflow.com/questions/753346/how-do-i-set-the-timezone-for-perls-localtime for more details

vicfn
  • 346
  • 1
  • 7
  • The code for GMT would be `TZ=GMT perl blah.pl`? – Thilo Mar 12 '13 at 03:10
  • Pretty much. You can try it out yourself with print(scalar localtime); – vicfn Mar 12 '13 at 03:24
  • 1
    This was the right answer, but the community tends to frown on brief link based answers. The answer here **is** simple to explain, but usually it's not asking much to provide an inline example. I'm giving you the +1 anyway. – Andrew B Mar 12 '13 at 03:44