in reply to Remove empty element.
Do you have any better idea to avoid the empty element ?
Yeah, don't use split to parse something that isn't a uniform list.
At a minimum, you could use the following:
my @var = $test =~ /\d+/g;
A little more flexible:
my ($list) = $test =~ /\[ ( [^\]]* ) \]/x; my @var = split /,/, $list;
By the way, the following needlessly creates two variables that are never used (and issues a warning for having two variables with the same name):
my $empty; my ($empty,@var) = ...;
You want:
(undef, my @var) = ...;
Update: Fixed pattern.
|
|---|