Changeset 31863


Ignore:
Timestamp:
2017-08-09T19:23:08+12:00 (4 years ago)
Author:
ak19
Message:

Additional changes to previous commit so that the new util::print_env can print to the specificed output handle (STDERR, STDOUT or file).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/util.pm

    r31862 r31863  
    2727
    2828use strict;
     29no strict 'refs'; # make an exception so we can use variables as filehandles
    2930use FileUtils;
    3031
     
    582583# debug aid
    583584sub print_env {
    584     my @envvars = @_;
    585 
     585    my ($handle, @envvars) = @_; # print to $handle, which can be STDERR/STDOUT/file, etc.
     586   
    586587    if (scalar(@envvars) == 0) {
    587     print STDERR "@@@ No env vars requested\n";
    588    
     588    #print $handle "@@@ All env vars requested\n";   
    589589   
    590590    my $output;
     
    596596    }
    597597   
    598     print STDERR "@@@ Environment was:\n********\n$output\n*******\n";
     598    print $handle "@@@ Environment was:\n********\n$output\n********\n";
    599599    } else {
    600     print STDERR "@@@ Environment was:\n********\n";
     600    print $handle "@@@ Environment was:\n********\n";
    601601    foreach my $envvar (@envvars) {
    602602        if(defined $ENV{$envvar}) {
    603         print STDERR "\t$envvar = ".$ENV{$envvar}."\n";
     603        print $handle "\t$envvar = ".$ENV{$envvar}."\n";
    604604        } else {
    605605        $envvar = uc($envvar);
    606606        if(defined $ENV{$envvar}) {
    607             print STDERR "\t$envvar = ".$ENV{$envvar}."\n";
     607            print $handle "\t$envvar = ".$ENV{$envvar}."\n";
    608608        } else {
    609             print STDERR "Env var $envvar was not set\n";
     609            print $handle "Env var $envvar was not set\n";
    610610        }
    611611        }
    612612    }
    613     print STDERR "@@@*******\n";
     613    print $handle "********\n";
    614614    }
    615615}
Note: See TracChangeset for help on using the changeset viewer.