Wow! Now that's a great answer!
Let me just add the following, since it took me a few minutes to see exactly what you were doing, as well as making it conform to the original requirements for the output:
$_ = "abc"; # Regex match of /.../ uses $_ when =~ is unspecified
# Nicely solves the problem stated, and demonstrates list assignment
# to a regex capture.
#
@matches = m/(((a)b)c)/ and print join "\n", reverse @matches;
I realized a "reverse" was necessary, and then immediately fell into the trap of putting it before the "join". I like your answer a lot for its succinct approach! |