in reply to pipe operator for windows

If the error message you've quoted is all that you're seeing ("tshark: An error occurred while printing packets: Invalid argument"), that strikes me as really poor error reporting by the tshark author(s). You should follow BrowserUK's advice, and when you see the contents of $tsharkcmd as printed by your script, you should copy/paste that string onto the command line to run it manually and see if you get the same error message.

I looked up the tshark man page, and it seems like your command-line string should be ok, unless (a) as suggested by NetWallah, you forgot to provide an input file name when you ran your script, or (b) you've provided an input file name that doesn't exist (or couldn't be found by tshark, because you didn't provide the correct path as part of the file name), or (c) any of the 15 strings you're using as values for "-e" options happens to be incorrect.

As for your two "open" statements, did you leave out some lines of code in what you've posted? If not, then your script isn't really finishing the job: you need to read from the TSHARK file handle, and write to the OUT file handle, but there's nothing in the OP code to do that.

Actually, you don't need to use file handles at all; just append " > $output" at the end of the command-line string, and do:

system( $tsharkcmd );