in reply to Re: Split Operation
in thread Split Operation

This fails:
my $test = "[a,b],c,'d',[e,[f,g,h,[i,j],k,l],m,n],o,p"; my @array = eval ( $test );
This succeeds:
my $test = "[a,b,],c,'d',[e,[f,g,h,[i,j,],k,l,],m,n,],o,p"; my @array = eval ( $test );
Don't forget no strict 'subs'; or else all those unquoted single characters will be treated as barewords!

Replies are listed 'Best First'.
Re^3: Split Operation
by JadeNB (Chaplain) on Aug 03, 2009 at 15:22 UTC
    The only difference that I can see is that the second code has (apparently spurious) commas at the end of every arrayref—is that correct? Why is it necessary?

    Of course you're right that what I wrote is far from strict-safe—thanks! Making it so would probably be harder than just giving the kind of solution the OP wanted, though. :-)

Re^3: Split Operation
by xtype (Deacon) on Aug 03, 2009 at 19:08 UTC
    use strict; my $test="[a,b],c,'d',[e,[f,g,h,[i,j],k,l],m,n],o,p"; $test =~ s/([a-zA-Z])/"$1"/g; my @array = eval ( $test );