Comp sci: Perl vs C: command-line arguments

Self-tutoring about computer science: the tutor notices a difference he finds surprising between Perl and C.

Today, my finding is that, with the command-line program call

perl f1.pl Hello!

Hello! is the zeroth command line argument ($ARGV[0]). I wouldn’t have thought so, yet it seems to be true.

In C, though, the command-line program call

./f1 Hello!

considers Hello! as the argv[1] (which is what I’d expect).

How Perl and C differ in this way I find very surprising, and barely believe it. However, my experience today suggests it’s true.

Source:

cyberciti.biz

Kernighan, Brian W. and Dennis Ritchie. The C Programming Language. New Jersey: Prentice Hall, 1988.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Leave a Reply