How can the code provided for parsing raw list output be improved to correctly handle the directory name and account for system-dependent variations?

The issue with the current code is that it assumes a specific format for the raw list output, which may vary depending on the system. To improve it, we can use regular expressions to extract the directory name and account for system-dependent variations in the output format.

// Sample raw list output
$rawListOutput = "drwxr-xr-x 2 user group 4096 Jan 1 12:00 directory_name";

// Regular expression to extract directory name
preg_match('/\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+(.+)/', $rawListOutput, $matches);

// Extracted directory name
$directoryName = $matches[1];

echo $directoryName; // Output: directory_name