Uri Guttman wrote:
> > please show your code. there is no way to help otherwise. s/// is not a
> > pattern matcher but a substitution operator. it uses regexes and can be
> > used to parse things.
> >
> > uri
> >

Here it is ...

$ cat test.txt
keyword1 word1, word2
  word3;
  blabla

  blabla


keyword2
  word4, word5,
  word6, word7, word8,
  word9;

  bla bla
  bla bla

keyword1
  word10, word11;


$ cat parse.pl
use warnings;

open FILE, "< test.txt" or die "Could not open $!";
$/ = undef;
$source = <FILE>;
close(FILE);


if ($source =~ m/keyword1\s*(\w*)(,\w*)*/s) {
    print("Match !\n");
    print("$1\n");
    print("$2\n");
}

$ perl parse.pl
Match !
word1
,


Here I would like to have 2 matches:
word1, word2
  word3;
and word10, word11;



Thanks to help me !

Olivier




-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to