title: How do I set the timezone for Perl's localtime()?
body: <p>In Perl, I'd like to look up the localtime in a specific timezone. I had been using this technique:</p>
  
  <pre><code>$ENV{TZ} = 'America/Los_Angeles';
  my $now = scalar localtime;
  print "It is now $now\n";
  # WORKS: prints the current time in LA
  </code></pre>
  
  <p>However, this is not reliable -- notably, if I prepend another localtime() call before setting $ENV{TZ}, it breaks:</p>
  
  <pre><code>localtime();
  $ENV{TZ} = 'America/Los_Angeles';
  my $now = scalar localtime;
  print "It is now $now\n";
  # FAILS: prints the current time for here instead of LA
  </code></pre>
  
  <p>Is there a better way to do this?</p>