Dear Happy.Barney
I tested your perl source code,You have splited the scalar value based on the open and close bracket.So it is failing one of the test case.I gave following input/output.
#!/usr/bin/perl
use strict;
use warnings;
my $test="[a[a]]";
my @stack = [];
for (split /([\[\],])/, $test) {
next
unless length $_;
next
if $_ eq ',';
push @stack, [] and next
if $_ eq '[';
push @{ $stack[-2] }, pop @stack and next
if $_ eq ']';
push @{ $stack[-1] }, $_;
}
my $retval = $stack[0];
use Data::Dumper;
print Dumper($retval);
$VAR1 = [
[
'a',
[
'a'
]
]
];
The output should be as following.
$VAR1 = [
[
'a[a]'
]
];