Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: user input file

by kennethk (Abbot)
on Jun 19, 2013 at 13:36 UTC ( #1039778=note: print w/replies, xml ) Need Help??

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 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?


        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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1039778]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (9)
As of 2017-01-18 22:18 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (165 votes). Check out past polls.