Thursday 23 January 2014

Read command line arguments in Perl

In Perl, the command line arguments are stored in the array @ARGV.

So the first argument passed can be displayed by $ARGV[0]

The second argument passed can be displayed by $ARGV[1] and like wise.

Eg:

If you run a script and pass 3 command line arguments to it :

./eg_script.pl Ironclad Writer 123

The first argument $ARGV[0] = "Ironclad"

The second argument $ARGV[1] = "Writer"

The third argument $ARGV[2] = "123"

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
eXTReMe Tracker