dumping environment etc from batch perl script

n1vux on 2010-02-24T05:37:29

use Data::Dumper;
print Dumper([       # like ...
       {  X=>$^X},   # which perl 
                     # but not fooled by #! 
       {V0 =>  "$]", # perl -v , ditto 
         V => $^V lt v5.9.0 
            ? q(v).(join(q(.),
                      (map {ord} 
                          split(//,$^V)))) 
            : "$^V"} ,
       { ENV => \%ENV} , # like env
                         #  but in actual context
       { INC =>\%INC}  , # incomparable
      ]);

The ugly version of V for Version is to handle 5.6-5.9 v strings and 5.10+ version objects without knowing which, if you don't want $] to mess up your syntax highlighting and don't want \005 to trip a terminal echoback string when it vString doesn't print.