我有以下Perl语言代码:
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my $DF = "/usr/bin/df -Pk"; # HP-UX
my @temp = split /\n/, `$DF`;
shift @temp;
print Dumper \@temp;
输出如下(为了更好的可读性而缩短):
$VAR1 = [
'/dev/vg00/lvol6 114224 46304 67920 41% /home',
'/dev/vg00/lvol7 8340704 4336752 4003952 52% /opt',
'/dev/vg00/lvol4 520952 35080 485872 7% /tmp',
];
我想将
@temp
数组(或创建一个新数组)转换为多维(数组数组),如下所示:$VAR1 = [
['/dev/vg00/lvol6', 114224, 46304, 67920, '41%', '/home'],
['/dev/vg00/lvol7', 8340704, 4336752, 4003952, '52%', '/opt'],
['/dev/vg00/lvol4', 520952, 35080, 485872, '7%', '/tmp'],
];
有人帮忙吗?提前致谢! :)
最佳答案
@temp = map [ split ], @temp ;