in reply to diamond operator

<> reads from @ARGV, so you can just modify @ARGV if you want special behaviour. In your case, remove the first element from @ARGV, or use Getopt::Long to introduce a command line switch.

Replies are listed 'Best First'.
Re^2: diamond operator
by Anonymous Monk on Jun 09, 2009 at 13:30 UTC
    thanks for the reply.
    I see, so a shift will do the trick right ?
    shift @ARGV;

    oh jz, reading my post now I realized the C comments..please ignore it, I still learning..
Re^2: diamond operator
by Marshall (Canon) on Jun 09, 2009 at 16:33 UTC
    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.

      <> 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.