in reply to Setting values for undefined environment variables

jacques,
Since there could be a whole bunch:
sub ENV { defined $ENV{$_[0]} ? $ENV{$_[0]} : 'undefined' } print "$_ is ", ENV($_), "\n" for qw(many environment variables);

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Setting values for undefined environment variables
by jacques (Priest) on Oct 24, 2004 at 02:50 UTC
    Thanks, but one problem with this approach is that I am actually using a heredoc to print. I didn't say this in my OP. I better add an update.

      And that's a problem why?

      ... print <<"EOT"; The environment variable $foo is: @{[ ENV( $foo ) ]} That is all. EOT ...
        Fletch,
        If we are going to get silly, why not get ridiculous?
        #!/usr/bin/perl use strict; use warnings; package magic; sub ENV { defined $ENV{$_[0]} ? $ENV{$_[0]} : 'undefined' }; sub TIEHASH {bless {}, $_[0]} sub STORE {} sub FETCH {ENV($_[1])} package main; tie my %magic , 'magic'; print <<"--"; $magic{PATH} $magic{FOOBAR} --

        Cheers - L~R