On Monday 05 November 2007 07:45, Frank Bergemann wrote: > > sorry i was missing to tell, that i used the HERE script like syntax. > > Here's an example: > > ------------------------------------ > > #!/usr/bin/perl -w > > use strict; > > my $input = << "END_OF_INPUT"; > Hi there! > Here're some lines to match... > 1st some specific ones > some more > and finally this one > Now the list > A Headline > 1 2 3 4 5 > 6 7 8 9 10 > 11 12 13 14 15 > > Some final line > END_OF_INPUT > > printf ("### the input is <$input>###\n");
You want to use print instead of printf: print "### the input is <$input>###\n"; > my $parser = << "END_OF_PARSER"; > Hi there! > Here're some lines to match... > 1st some (specific) ones > some more > and finally this one > Now the list > A (Headline) > (?:(\\d+)[ ]+(\\d+)[ ]+(\\d+)[ ]+(\\d+)[ ]+(\\d+)\\n)* > Some final line > END_OF_PARSER Your pattern ()* is a list and the pattern will match every line but only capture the *last* line matched. To do what you want you have to loop through the lines individually. > if ($input !~ $parser) { > die "input does NOT match parser"; > } > > my @values = ($input =~ $parser); There is no need to match the regular expression twice: my @values = $input =~ $parser or die "input does NOT match parser"; > printf ("extracted values (" . scalar(@values) . "):\n"); You want to use print instead of printf. > foreach (@values) { > printf ("\t$_\n"); You want to use print instead of printf. > } > printf ("\n"); You want to use print instead of printf. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/