in reply to Re^2: Using qw to check for balanced parentheses (oops)
in thread Using qw to check for balanced parentheses
Simplified return value and shortened code by avoiding needless use of $_:
sub balanced { (my $s = shift) =~ s/[^()]//g; eval "qw($s); 1" }
Or in 5.14+:
sub balanced { my $s = shift =~ s/[^()]//rg; eval "qw($s); 1" }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Using qw to check for balanced parentheses (oops)
by Anonymous Monk on Oct 23, 2014 at 16:04 UTC |