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"; }