Home > Archive > PERL Beginners > April 2004 > RE: Looking for a equivalant function in Perl for main(int argc,
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
RE: Looking for a equivalant function in Perl for main(int argc,
|
|
| Bob Showalter 2004-04-28, 4:41 pm |
| Shilpa Arvind wrote:
> Hi,
>
> In C programming language we have a function which looks like this:
>
> main(int argc, char *argv[ ]).
>
> Is there a equivalant function in Perl. I was looking at @ARGV but i
> feel it does not behave the same way as the above function does. I
> might be wrong.
@ARGV does not contain the program name as the first element. That is placed
in $0 instead. Read the relevant sections in perldoc perlvar. Also read the
section on "C Traps" in perldoc perltrap.
| |
| Jeff 'Japhy' Pinyan 2004-04-28, 4:41 pm |
| On Apr 28, Shilpa Arvind said:
>In C programming language we have a function which looks like this:
>
>main(int argc, char *argv[ ]).
>
>Is there a equivalant function in Perl. I was looking at @ARGV but i feel it
>does not behave the same way as the above function does. I might be wrong.
There is no need for a main() function in Perl. As for what argc and
**argv hold, you can get the name of the program from $0, and the
arguments to your program in @ARGV. The number of arguments to your
program is scalar(@ARGV), or ($#ARGV+1).
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
|
|
|
|
|