in reply to Re: diamond operator
in thread diamond operator

Update: ran some more code and the first part here is not right.

Just a little point, <> reads from STDIN, not @ARGV. Looks like a typo to me.

For the poster, I showed some code below. In Perl @ARGV has the command line args. In C, char **argv, array of pointers to strings. Way easier in Perl! Perl does have equivalent to C getopts with many flavors.

Replies are listed 'Best First'.
Re^3: diamond operator
by Corion (Patriarch) on Jun 09, 2009 at 16:41 UTC

    <> only reads from STDIN if @ARGV is empty:

    @ARGV=($0,$0,$0); print for <>;
      I learned something. THANKS Corion!
      I would not have thought that: while(<>) would try to open a command line arg as a file! But evidently it will!

      C:\TEMP>cat corion.pl #!/usr/bin/perl -w use strict; while (<>) { print $_;} C:\TEMP>perl corion.pl a b c Can't open a: No such file or directory at corion.pl line 4. Can't open b: No such file or directory at corion.pl line 4. Can't open c: No such file or directory at corion.pl line 4.