Win Vista, 32bit, Strawberry PERL 5.12.0

File cnu.pl (3 lines):

use strict; print @ARGV; <>; 

When calling: "perl cnu.pl 1 2 3" gives

Can't open 1: No such file or directory at cnu.pl line 3.
Can't open 2: No such file or directory at cnu.pl line 3.
Can't open 3: No such file or directory at cnu.pl line 3.
123

When calling: " cnu.pl 1 2 3 " requests the input line and terminates without displaying anything on the screen.

Those. it can be seen that when called through the interpreter, the PERL treats digits both as files for reading and as parameters.

Is it possible to somehow change his behavior so that he does not try to open files with such names? And most importantly: how to organize the reading of parameters if the script is launched like this: " cnu.pl 1 2 3 " (second case)?

    2 answers 2

    Remove '<>';

     use strict; use Data::Dumper; print Dumper(\@ARGV); 

      can be so:

       use strict; print while $_ = shift @ARGV; <>; 
      • And what should do the line <>; ? Pause - alexlz