Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.92k stars 550 forks source link

Perl Bug handling arguments passed to a script #814

Closed p5pRT closed 20 years ago

p5pRT commented 24 years ago

Migrated from rt.perl.org#1742 (status was 'resolved')

Searchable as RT1742$

p5pRT commented 24 years ago

From John_Amelia@NEWYORKLIFE.COM

bugreport

p5pRT commented 24 years ago

From @tamias

On Thu\, Nov 04\, 1999 at 09​:43​:28AM -0500\, John Amelia wrote​:

When executing a perl script arguments such as perl_script file arg1 arg2 arg3 generate error messages.

  Can't open arg1​: A file or directory in the path name does not exist\.
  Can't open arg2​: A file or directory in the path name does not exist\.
  Can't open arg3​: A file or directory in the path name does not exist\.

Here is a copy of the script ---

  NV6KNCC cat do\_rshell\.pl
  \#\! /usr/local/bin/perl

  $rcmd = @​ARGV\[0\];

  while\(\<>\) \{
        chomp;
        $R = $\_;
        @&#8203;cmd = \("/u/t01bhjt/do\_router\_rshell"\, $R\, $rcmd\);
        system\(@&#8203;cmd\);
  \}

And what did you expect to get when you tried to open files that don't exist?

The input operator \<>\, when used without an explicit filehandle\, opens the files named in @​ARGV in turn. Each element in @​ARGV is treated as a filename. This is documented in perlop.

It appears that you need correct your script so that it does not treat the extra arguments as filenames.

Ronald