in reply to Re^2: Chomp, Concatenation and paths
in thread Chomp, Concatenation and paths

The anonymous frère likely meant to tell you that the environment is mapped bidirectionally into Perl as the %ENV hash. See perlvar about all special Perl variables.

Replies are listed 'Best First'.
Re^4: Chomp, Concatenation and paths
by Mad_Mac (Beadle) on Jun 25, 2010 at 19:58 UTC

    OK, I get it. I could use that instead of a system call. I don't see how that saves me a step, other than maybe I don't need to chomp?

      "One step" is quite an understatement. You're spawning a new process (which involves fetching %ENV), executing a shell, executing a shell command, checking for errors (or not) and parsing the response in order to get a value Perl already had to begin with.

      Using $ENV{localappdata} saves an incredible number of steps.

      Also, it doesn't return "Echo is on" if the variable isn't set, and it's portable.

      Update: Added last paragraph.

      print "$ENV{localappdata}\\someApplication\\";