echo foo | perl -wpe 'your code here' file