Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Split Operation

by santhosh_89 (Scribe)
on Aug 03, 2009 at 05:53 UTC ( #785346=note: print w/replies, xml ) Need Help??


in reply to Re: Split Operation
in thread Split Operation

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]' ] ];

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://785346]
help
Chatterbox?
[virtualsue]: I have made a post for the first time in ... years
[marto]: hey virtualsue!
Eily thought about Neko Case first, something might be wrong with my brain's wiring
[virtualsue]: I recommended dbic-migration even though I am having trouble with it this week. It might be my fault.
[ambrus]: wow! I haven't seen you here for a long time, virtualsue
virtualsue waves back
[Eily]: it would have been 2 years in 2 weeks actually. And welcome back virtualsue :)
[Corion]: I think I saw virtualsue more recently in person than online :-D
[virtualsue]: It's true that there was a bigger gap between the 2 yr old post and the one before it
[ambrus]: yes, I probably just didn't see you two years ago, because I'm not in perlmonks much

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2017-09-26 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (295 votes). Check out past polls.

    Notices?