The quick way - but maybe not the best: reformat your rules on the fly until they are valid perl, and eval them (you wrote "write a new package" which you would then use, but that's just the same - the underlying inclusion mechanism is a string eval). Roughly something like this:
my %hash = ( genre => 'Rap', artist => 'Mozart', ); sub genre () { $hash {'genre'} } sub artist () { $hash {'artist'} } sub album () { $hash {'album'} } my $file = 'some_file.mp3'; $_ = "RULE = (genre eq Rap or genre eq HipHop) and artist ne RunDMC to + /music/Other"; if(s/^RULE\s*=\s*//) { my ($cond, $target) = split /\s+to\s+/, $_; eval $cond and print "rename $file, $target/$file\n"; }
Of course you must make sure your rules don't look like
i.e. you will have to sanitize your rules, and you'll probably run with -T (taint checks on).RULE = (genre eq Rap or genre eq HipHop) and artist ne RunDMC to `rm - +r /music/Other`
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
In reply to Re: file routing
by shmem
in thread file routing
by former33t
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |