in reply to user input file

The correct method for taking command line parameters into a Perl script is to use the @ARGV array. Your example might look like
open(FILE,"<", $ARGV[0]) or die "Open failed for $ARGV[0]: $!"; + my @lines=<FILE>;
which the user would invoke as
$ perl script.pl Working_On.csv
Note as well that I've added a test to see if the file open succeeded, and added a diagnostic in case it didn't. See Simple Opens in perlopentut.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Replies are listed 'Best First'.
Re^2: user input file
by torres09 (Acolyte) on Jun 19, 2013 at 13:47 UTC

    I am working on windows , not unix so there will be no invocation . I tried your way but it does not work , may be because of OS

      If you drag a csv file on to the script, it can be configured to read the file name from @ARGV. How are you planning to have the user invoke it?

      --MidLifeXis

        I am working on Padre , here the script has been written so I wish that user should input the file name on command prompt , when we run it . In padre we have an option to run the script , which gives a cmd with result on it , we can also give inputs from cmd as well