http://qs321.pair.com?node_id=699760


in reply to File created but blank

If you checked the return status of your open(PL, ...) call, I bet you would find out that it failed. Since there is no pipe symbol at the end of the file name, you are actually asking perl to read a file with a lot of shell metacharacters in it.

An easier way is just to use system() to directly invoke the command:

system("grep 'packet loss' ... > /home/.../$TARGET_HOST.PL.log");
If you wanted to open a pipe from the command, you would need to terminate it with a pipe symbol, e.g.
open(PL, "grep ... | ... |") or die "unable to open pipe from grep command: $!"; while (<PL>) { ... } close(PL);