foreach $track (@playlist) { print "| Track: $track\n"; unless (open PIPE, "-|") { # I'm the kid $SIG{INT} = 'IGNORE'; exec "ssh $machine \"cat $soundroot/$track\" | mpg123 -"; die "Cannot exec ssh: $!"; } # rest of your loop goes here }