#! /usr/bin/perl use strict; use Regexp::Common; my $string = "@ARGV"; print "$_\n" for $string =~ /(\w+|$RE{balanced}{-parens=>'{}'})/g;