in reply to Re^2: Remove empty element.
in thread Remove empty element.

The second example given by ikegami above should work for you , provided you have a defined separator that doesn't conflict with your data.

Replies are listed 'Best First'.
Re^4: Remove empty element.
by vinoth.ree (Monsignor) on Jul 14, 2009 at 07:06 UTC

    But I get the error as,

    Use of uninitialized value in split at santhosh.pl line 27. $VAR1 = [];

    Following is the code I tried

    use strict; use warnings; use Data::Dumper; my $test="[1,2second,3third,fourth]"; my ($list) = $test =~ /\[ ( [^\]] ) \]/x; my @var = split /,/, $list; print Dumper \@var;
      There's a slight error in the regex,
      my ($list) = $test =~ /\[ ( [^\]]+ ) \]/x;
      resolves your issue here

        Thanks its working fine