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'
        ];
$VAR1 = [
          'foo) (bar) (baz'
        ];
$VAR1 = [
          '(foo) bar)) (baz'
        ];
$VAR1 = [
          'foo bar'
        ];


.* is greedy. I suspect @text_inside_parens will never have more than one element in it.

Right, The point was, regexes could help, I never said it wasn't greedy or the example was 100% what he needed, just a suggestion for another place to start looking :)
(I figured it was a *little* better than `perldoc perlre` ;p)


Thanks for taking the time to do that example.

Lee.M - JupiterHost.Net

HTH,

Charles K. Clarkson

-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to