Just for the fun of it...
calling
diskutil_info("/")
will give you a record of all the information diskutil -info returns.
Handy. I would have done it with -plist, I think, rather than trying to parse the output of the non-plist form...
while (<>) {
chomp;
next if /^$/;
s/^\\s+//;
s/\\s+$//;
if (s/^(\\w[^:]+?)\\s*:\\s*//) {
$last_key= $1;
$info{ $last_key }= $_;
next;
}
$info{ $last_key }.= qq(\\n).$_ if $last_key;
That can be simplified to two regex matches instead of four:
while (<>) {
if (/^\\s*(\\w[^:]+?)\\s*:\\s*(.*?)\\s*$/)
{
$info{$last_key=$1} = $2;
next;
}
elseif ($last_key && /\S/)
{
chomp( $info{$last_key} .= qq(\\n) . $_ );
}
}
--
Mark J. Reed <