in reply to How to prevent a value from being repeated?
In all but the first iteration, the last regexp isn't matched, resulting in a repeat of the article title. (I guess that the backreference from the regexp to capture the article title is assigned to $source_journal, which is then printed)
Captures like $1 are only valid if a regex actually matched... So the solution would be to test if it matched, and assign some other (default) value to $source_journal in case it didn't.
if ($new_url =~ m{(...)}) { $source_journal = $1; } else { $source_journal = '(not specified)'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to prevent a value from being repeated?
by turbolofi (Acolyte) on May 12, 2009 at 13:55 UTC |