[Linux & perl] Command line arguments

  • Thread starter Thread starter rama1001
  • Start date Start date
  • Tags Tags
    Line Linux
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
4 replies · 3K views
rama1001
Messages
130
Reaction score
1
Hi,
I am in process of leraning Linux. I have been structed in understanding of command line arguments and @ARGV in perl.
What is command line arguments? Really, i have no idea.
Though, i have implemented a short program in perl to list this command line arguments but i couldn't see any list when i run my program.

#! /usr/bin/perl

foreach (@ARGV) {
print "$_\n";
}


Can anyone help with basic information what does this command line arguments and how the perl is accessing them?

Thank you.
 
Physics news on Phys.org
Yes, this i understood before itself. What is use of this? if it prints argumetns then what? How it would be useful in practically?
 
it's just a demonstration of how to get the command line arguments, without regard to how you're going to use them.

By using command-line arguments, you can write scripts that behave like Unix/Linux command-line commands.
 
Type at your command prompt:

ls

ls *.pl

ls -al

It is the same command (list) but in each case output is different - thanks to the command argument.