[Linux-disciples] Perl: displaying the part of a match that failed
Adam Rosi-Kessel
adam at rosi-kessel.org
Fri Jun 24 15:18:43 EDT 2005
On Fri, Jun 24, 2005 at 03:16:30PM -0400, Stephen R Laniel wrote:
> It's not always true, but most of the time you should assume
> that I've not made a drastically stupid mistake. *Most* of
> the time.
I could post some links from the archives, but I'll refrain for now...
> * a block is composed of multiple statements surrounded by
> braces.
> * a declaration is an element name followed by a block.
> * a stylesheet is one or more declarations.
> Then at the end, I do something like
> $_ = join '', <>;
> Now I'm parsing the whole stylesheet against the definition
> of a stylesheet, and asking "Does this whole stylesheet
> parse?" If it doesn't, I want to display the part that
> didn't.
I think you're hoping that there is some secret regexp extension that
solves it for you, but I'm pretty sure that doesn't exist.
You could just do:
s/$block//gi;
(and cycle through all your matching regexps)
And then just print out $_ after it's done. (or presumably make a copy
of $_ to do the operation on).
--
Adam Rosi-Kessel
http://adam.rosi-kessel.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20050624/a5110584/attachment.pgp
More information about the Linux-disciples
mailing list