Rabenschwinge has asked for the wisdom of the Perl Monks concerning the following question:
Executing this code always produces:my $comment = '^(\/\*.*\*\/\;)(.*)'; [...] while ($statement !~ m{$comment}s) { $statement .= <$file> or die "Pre +mature EOF.\n"; } print "Found type 1 comment: $1\n";
Use of uninitialized value in concatenation (.) or string at ./test.pl + line 16, <$file> line 1. Found type 1 comment:
For the line containing the print statement, meaning that $1 is not defined. But I don't understand how that could be. If the regular expression matched there should be something captured, and if not the line wouldn't even be executed...
I tried to reformulate this as while (!($statement =~ m{$comment}s)) but that didn't help either. Could anyone tell me, why nothing's captured here?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Capture not working
by ikegami (Patriarch) on Jan 08, 2009 at 13:26 UTC | |
|
Re: Capture not working
by cdarke (Prior) on Jan 08, 2009 at 13:35 UTC | |
by moritz (Cardinal) on Jan 08, 2009 at 13:51 UTC | |
by ikegami (Patriarch) on Jan 08, 2009 at 13:43 UTC | |
by Anonymous Monk on Jan 08, 2009 at 14:03 UTC | |
by ikegami (Patriarch) on Jan 08, 2009 at 14:32 UTC | |
by Corion (Patriarch) on Jan 08, 2009 at 13:39 UTC |