Some research tells me that Perl is a good scripting language to do this in, and I can find examples online, but I don't know how to work them into the right format for use with Alfred Workflows. This is what I have now, but it isn't working... (trying to replace "apple" with "pear" as a test)
$query = "{query}";
-p -e 's/apple/pear/g;' $query
print $query;