"Charles K. Clarkson" wrote: > JupiterHost.Net <[EMAIL PROTECTED]> wrote: > : > : [EMAIL PROTECTED] wrote: > : > Is there a module out there that I can use to parse > : > a text line and return the pieces that are enclosed > : > in paren's? > : > : You don't need a module for that just use regex's: > : > : my @text_inside_parens = $string =~ m/\((.*)\)/g;
> Let's test it. > > use strict; > use warnings; > use Data::Dumper 'Dumper'; > > foreach my $string ( > '(foo) (bar)', > '(foo) (bar) (baz)', > '((foo) bar)) (baz)', > '(foo bar)', ) { > > my @text_inside_parens = $string =~ m/\((.*)\)/g; > print Dumper [EMAIL PROTECTED]; > } > > __END__ > I get: > > $VAR1 = [ > 'foo) (bar' I see. Someone dun fergot the lazy symbol, huh? ... > .* is greedy. I suspect @text_inside_parens will > never have more than one element in it. good point. ... my @text_inside_parens = $string =~ m/\((.*?)\)/g; print Dumper [EMAIL PROTECTED]; } __END__ $VAR1 = [ 'foo', 'bar' ]; $VAR1 = [ 'foo', 'bar', 'baz' ]; ... Joseph -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>