bc may be a good hint, but regarding your wording, there's technically nothing wrong with the way the OP is opening the file. The only thing that might be "wrong" with it is that there's no error checking - which your example doesn't do either. e.g. open(FILE, "-|", "bc < res.txt") or die "failed to pipe: $!";