I had to laugh when I saw your code. You're a bash programmer, right? So was I when I first started and this is a classic bashy mistake: Unlike bash, perl won't do command interpolation 'in-line'. You'd need two commands, like: