so I was testing some stuff I want to do in a large project.. I wanted my configuration files to contain perl's regeular expressions to allow the configs to be as flexible as possible.. so I threw together a nasty little test script (doesn't use strict or do any error checking) but basically proves that it can work and that its just pretty damn cool :)
test.pl
#!/usr/bin/perl
open(R, "file.r");
while(<R>) {
chomp;
push @REG,$_;
}
open(I, "file.i");
while(<I>) {
chomp;
foreach $regex (@REG) {
if(/$regex/) {
print "$_ matched $regex\n";
for $i (1..5) {
if($$i) {
print "\t\$$i: $$i\n";
}
else { last; }
}
}
}
}
file.r:
^a
interface (POS(\S*))
fun
file.i:
interface POS5/7
a dog
a
ant eats stuff.
b
stuff
yields:
interface POS5/7 matched interface (POS(\S*))
$1: POS5/7
$2: 5/7
a dog matched ^a
a matched ^a
ant eats stuff. matched ^a
Perhaps I'm a just easy to impress, but does anyone else see the beauty and power of this? :)
its those little revelations that make life more fun :)
anyone else have any "little things" that have made their life infinitely more fun?