I'm playing around with perl but I can't seem to get the desired output from this code:
Code:
#!/usr/bin/perl
$mypath = system("echo \$PATH > 2&>1");
@path = split(/:/, $mypath);
foreach $unique_path (@path)
{
$this_path .= $unique_path;
}
print $this_path;
This is what I've ended up with (it's probably wrong). What I'm after is this. I need to set, as a variable, the environment path. Then I need to split path variable into an array. Afterwhich, I need to cycle through each unique path to run a test against it... The print statement is just there to see if $PATH is "put back together" after cycling through the array.
Here is the equivilent php code I would use...
Code:
$path = shell_exec("echo \$PATH");
$path = explode(":",$path);
foreach ( $path as $key => $value )
{
echo $value."<br>";
}
This outputs each unique path onto it's own line...
Any help would be appreciated...