Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^3: multiple-pass search?

by jdporter (Paladin)
on Dec 10, 2021 at 01:57 UTC ( [id://11139523]=note: print w/replies, xml ) Need Help??


in reply to Re^2: multiple-pass search?
in thread multiple-pass search?

So I take it the filename will have the exact pattern abstract-NNN.tex. If so, the regex you gave is too broad. It will match, for example, nonabstract-000stexts. You need to anchor the beginning and end, and escape the dot: /^abstract-(\d{3})\.tex$/

Replies are listed 'Best First'.
Re^4: multiple-pass search?
by propellerhat (Novice) on Dec 10, 2021 at 02:18 UTC

    I understand; I plead ignorance, and have made note. However, I am searching in a directory in which there are only *-xxx.tex files, with separate directories for articles, abstract, and catalogue.

      However, I am searching in a directory in which there are only . . .

      Famous last words . . . :)

      Which is of course why he's pointing out that you've effectively made that assumption but not implemented it in your code and hence your code is vulnerable to things changing. If you're not going to add anchors you'd probably at the least want to add some sort of comments to this effect about the expectation(s) and mentioning when it can fail. Down the road in n months/years the person fixing the inevitable failure (either future-you or some successor) has something to go on then.

      We'll all cut corners like this at times (see Laziness and Impatience), it just sometimes helps to make it obvious for when they grow pointy again for whatever reason (and your Hubris can gloat that you foresaw this very problem).

      The cake is a lie.
      The cake is a lie.
      The cake is a lie.

      If that really is a safe assumption, then the code I gave in my solution will work just dandy.

      I thank you-all for your recommendations. After a single run, most of these Perl routines are destined for the dumpster; they are for my personal use in organizing a small cache of Bible studies. A few lines of Perl script which run in a few seconds, save me hours of typing. The studies, many of which are incomplete, I am editing and publishing, on the web (PDF and EPUB). I am working alone, so whatever does not get published before I die most likely shall never be seen.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139523]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-03-29 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found