0

Dumper(@releases) 具有以下功能

$VAR1 = '\projects\proj mypac : test / 04.00.00; 0';

当我打印($releases[0])时,它给出

\projects\proj mypac : test / 04.00.00; 0

我想要单个元素,例如

$releases[0] = \projects\proj;
$releases[1] = mypac;
$releases[2] = mypac;
$releases[3] = 04.00.00;
$releases[4]  = 0;

我怎样才能做到这一点?

4

1 回答 1

3

只是split你的字符串。

use strict;
use warnings;

my $string = '\projects\proj mypac : test / 04.00.00; 0';

my @fields = split m{\s*[:/;]?\s+}, $string;

use Data::Dumper;
print Dumper \@fields;

输出:

$VAR1 = [
          '\\projects\\proj',
          'mypac',
          'test',
          '04.00.00',
          '0'
        ];
于 2014-08-20T05:24:32.187 回答