Close
Close

Problems with command line arguments

   vijeth.j

When I compile and run the following script:

print "What is your name?\n";
$name = <>;
#chomp($name);
print $ARGV[0],$ARGV[1],"\n";
print "Your name is ",$name;

When I try to compile and run with the command: perl filename.pl 0 1 I get the following messages in the terminal.

 

Can't open 0: No such file or directory at commandline_error.pl line 2.

Can't open 1: No such file or directory at commandline_error.pl line 2.

 

I believe the compiler is assuming 0 and 1 as filenames rather than command line arguments. I would like to know how to make sure that compiler treats them as command line arguments and not as filenames. I am a beginner in Perl. Any pointers would be greatly appreciated.


Answers

Ask Yours
Post Yours
Write your answer