$ 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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |