[wellylug] Perl problem -- warning, I know nothing about Perl syntax ;-)y
Richard
richard at redspider.co.nz
Mon Mar 22 21:54:05 NZST 2004
> Hi,
>
> This innocuous looking line of code:
>
> if ($fentry->{regexp}) { @toadd = grep { /$name/ } @$rpms }
>
> is giving me this error:
>
> Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE / at ....
>
> What an earth does that mean?! Is the '<-- HERE in m/* <-- HERE /' a
> standard perl way of signifying an error?
In, short, it means that $name starts with a *. You can't do that.
In long, what you're looking at is a regular expression with variable
interpolation. It takes the value of $name and uses it as a regular expression
to match against the array $rpms, returning an array of entries that match.
The problem is that $name isn't containing a valid regular expression. A * is a
qualifier, something that operates in concert with something else. In this case,
a * means "none, or more of the character before me". But $name starts with a *,
therefore there isn't a character in front of it, and therefore, you get an
error.
If you wish to match "anything", you would do .* instead.
--
Richard Clark,
Analysis and Design,
Red Spider (http://redspider.co.nz/)
(+64) 021 478 219
More information about the wellylug
mailing list