I've had this code for a while, for unix. By default, it prints out PATH, but it can also accept another environment variable name, such as MANPATH or LD_LIBRARY_PATH. The POD explains it all:
$ perldoc hpath
=head1 NAME B<hpath> - Human-readable print of Unix PATH variable =head1 SYNOPSIS hpath [name] Options: name Name of an environment variable =head1 DESCRIPTION Prints each item of a path-type environment variable onto its own line +. Useful for displaying PATH variable, for example. A path-type variabl +e is really any variable which is a colon-separated list. Takes as input an environment variable name. Input need not be all upper case. However, the actual variable name m +ust be all upper case. Input need not be the full variable name. However, the abbreviated in +put must allow for "PATH" to be appended to it. For example, "man", "MAN", "manpath" and "MANPATH" will all resolve to "MANPATH". If no input is given, the default is "PATH". Output is STDOUT. =head1 EXAMPLES Print the value of the PATH environment variable, one directory per li +ne: hpath Print the value of the MANPATH environment variable: hpath man Print the value of the LD_LIBRARY_PATH environment variable: hpath LD_LIBRARY_PATH =cut use strict; use warnings; my $name = (@ARGV) ? uc shift : 'PATH'; # If environment variable does not exist, try appending "PATH" to its +name: my $path_var = exists $ENV{$name} ? $ENV{$name} : $ENV{$name . 'PATH'} +; if (defined $path_var) { my @list = split /:/, $path_var; print "$_\n" for @list; }

In reply to Re: Road to a readable path (unix) by toolic
in thread Road to a readable path by wol

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.