Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: PCRE help with negative match

by sundialsvc4 (Abbot)
on Aug 13, 2013 at 04:30 UTC ( #1049210=note: print w/replies, xml ) Need Help??

in reply to PCRE help with negative match

Like many others, I do not see an immediately-obvious “bright-line rule” here that could easily be expressed in a regex.   And even if I did, I think that the resulting “solution” would be very, very difficult to maintain over time.

Therefore, if it were me, I would simply split() the string by dashes, then follow this by a series of explicit conditional tests, such as the next unless statements in this snippet:

while (<FILEHANDLE>) { my @pieces = split(',', $_); next unless ($pieces[0] eq '8898'); next unless ($pieces[2] eq 'sdfgh1'); ... # IF WE MAKE IT ALL THE WAY HERE IT'S A GOOD REC DO SOMETHING }

It is, I think, “immediately obvious” what this code is doing, and it is also obvious how to extend it and/or change it without breaking it.   Whereas it is a very difficult thing indeed to have to deal with “clever, efficient” code that “seemed to work okay” at the time that it was written but now rightly shows itself to be a house of cards.   I fear that “regex cleverness” would be nothing but trouble in the long run here.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1049210]
[shmem]: ctags is a program which (recursively) extracts the symbols from source and stores them in a one-file database. This allows you to query the locations where these symbols (e.g. a subroutine name) are used anywhere in the source code tree...
[shmem]: ...from inside the editor.
[shmem]: apt-get install exuberant-ctags
[Lady_Aleena]: I think I heard vim has a big learning curve.
[shmem]: then in the root of your source tree run: ctags -R
[shmem]: you get a file named tags where all symbols and the places where they are used are listed
[Lady_Aleena]: geany may not support that.
[shmem]: I see that there is a plugin geany-plugin- codenav
[shmem]: maybe that supports ctags, check the documentation

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2017-04-27 12:13 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (506 votes). Check out past polls.