Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

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.

Comment on Re: user input file
Select or Download Code
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2015-10-09 05:54 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (233 votes), past polls