Archive for the ‘perl’ Category


Extract and group SQL WHERE clauses


I’m just going through an exercise at the moment to check that an Oracle DB is properly indexed, and since all the queries are done from stored procedures, with 100,000+ lines of source sprinkled over hundreds of files, I wanted something to quickly snarf all the WHERE clauses out, rather than go looking for them by eye.

So I just scribbled down a silly perl script, catted all the PL/SQL source through it, and got a plausible-looking list of WHERE clauses, ordered by decreasing frequency of occurrence in the code.

Hooray! Time for a beer.


Copy by attribute


Here is a perl script I scratched together yesterday to help me file digital camera images faster (I keep them organized by date on our file server, but can never be bothered to run any of those feature-laden camera programs — I like having the camera, or its memory cards, just show to up as a file system I can yoink things out of).

I’ve written it in such a way that various other attributes of the files can be used as the basis for grouping them. It also supports only creating symlinks to files, rather than real copies, and doing that over multiple attributes per file (size, age, owner, etc.), so it could also be used to create sort-of attribute-based indexes of file systems, perhaps.

Or something.

Anyway, improvements and suggestions welcome.