% perl -lne 'printf "%-6s %s\n", $_, scalar(/^banana$/ .. /^grape$/)' fruit.txt apple banana 1 pear 2 peach 3 grape 4E0 orange