Perl Parsing Argument

i wanna passing an argument which read in a file or a set of files if the files are given in the command line, otherwise use STDIN if no file argument.
i got something like that, but it is not really working.
so can anyone help me? which one is better to use for and how? Use perl.

Thank you

use Getopt()::Long;
GetOptions( "file=s" => \$file );
$str = @ARGV ? $ARGV[0] : <STDIN>
chomp ($str = <STDIN>);