Help for this page

Select Code to Download


  1. or download this
    sub isBalanced {
        my $text= shift;
        my $brace= @_ ? shift : "{}";
    ...
        0 while $text =~ s/\Q$start\E[^\Q$brace\E]*\Q$end\E//g;
        return $text !~ /[\Q$brace\E]/;
    }
    
  2. or download this
    sub notBalanced {
        my $brace= 1 < @_ ? $_[1] : "{}";
        my $start= substr( $brace, 0, length($brace)/2 );
    ...
        }
        return $depth;
    }