I am trying to open the file received as argument.
When i store the argument in to the global variable open works successfully.
But
If I use give make it as my open fails to open the file.
What is the reason.
#use strict;
use warnings;
#my $FILE=$ARGV[0]; #open Fails to open the file $FILE
$FILE=$ARGV[0]; #Works Fine with Global $FILE
open(FILE)
or
die "\n ". "Cannot Open the file specified :ERROR: $!". "\n";
Unary open works only on package (global) variables. This is documented on the manpage.
A better way to open a file for reading would be:
P.S. always use
strictandwarningswhile debugging your Perl scripts.