Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default Perl Arguements

    I am having difficulty in getting the Perl Interpretor to recognize
    arguements submitted with a perl script. For example,I have a simple
    perl script like this called temp.pl

    print "ARGV0 : $ARGV[0]\n";
    print "ARGV1 : $ARGV[1]\n";
    print "ARGV2 : $ARGV[2]\n";

    If I run the script as 'temp.pl A B C',I get the following output:
    ARGV0 :
    ARGV1 :
    ARGV2 :

    If I run the script as 'perl temp.pl A B C', the arguements are then
    recognized and I get the following output:
    ARGV0 : A
    ARGV1 : B
    ARGV2 : C

    I do not understand why the difference, the perl scripts is running in
    both cases, but in the first case no arguements seem to be recognized.

    Thanks for any help, Paul
    Paul Guest

  2. Similar Questions and Discussions

    1. Off Topic: Active Perl Native Windows / cygwin perl
      I have both activestate windows native perl installed and the default cygwin perl. How can I have the cygwin shell use the windows perl rather...
    2. Control a non-perl image viewer from perl script
      Below is a (non-finished) script that trys to run a linux viewer called eog (eye of gnome) in a script that will eventually allow me to power thru...
    3. Re : Installing CPAN Perl Modules with Activestate Perl 5. v5.8
      Hi, In the process of trying to get perl modules installed, I downloaded over 300 Activestate specific perl modules and they work fine (of the ones...
    4. Effeciency question - perl scripts v's perl exe's
      Max Adams wrote: The only existing Perl compiler is part of perl. Anything else is just a packager that puts a perl, required modules, and the...
    5. How Can I Install PERL Modules w/o Upgrading PERL?
      Shalom! I absolutely hate it when I install a required module for one piece of software or another, and suddenly it begins installing the...
  3. #2

    Default Re: Perl Arguements

    Paul wrote:
    > I am having difficulty in getting the Perl Interpretor to recognize
    > arguements submitted with a perl script. For example,I have a simple
    > perl script like this called temp.pl
    > print "ARGV0 : $ARGV[0]\n";
    > print "ARGV1 : $ARGV[1]\n";
    > print "ARGV2 : $ARGV[2]\n";
    > If I run the script as 'temp.pl A B C',I get the following output:
    > ARGV0 :
    > ARGV1 :
    > ARGV2 :
    which operating sytem, which perl version?
    > If I run the script as 'perl temp.pl A B C', the arguements are then
    > recognized and I get the following output:
    > ARGV0 : A
    > ARGV1 : B
    > ARGV2 : C
    > I do not understand why the difference, the perl scripts is running in
    > both cases, but in the first case no arguements seem to be recognized.
    i don't understand the difference, either. for me it works, if
    i call the script with ./temp.pl (if the rights are set correctly):

    $ cat temp.pl
    #!/usr/bin/perl -w
    use strict;
    print "ARGV0 : $ARGV[0]\n";
    print "ARGV1 : $ARGV[1]\n";
    print "ARGV2 : $ARGV[2]\n";
    $ ls -l temp.pl
    -rwxr--r-- 1 tina users 115 Sep 8 23:27 temp.pl
    $ temp.pl A B C
    bash: temp.pl: command not found
    $ ./temp.pl A B C
    ARGV0 : A
    ARGV1 : B
    ARGV2 : C

    hth, tina
    --
    [url]http://www.tinita.de/[/url] \ enter__| |__the___ _ _ ___
    [url]http://Movies.tinita.de/[/url] \ / _` / _ \/ _ \ '_(_-< of
    [url]http://www.perlquotes.de/[/url] \ \ _,_\ __/\ __/_| /__/ perception
    - the above mail address expires end of december 2003 -
    Tina Mueller Guest

  4. #3

    Default Re: Perl Arguements

    Paul wrote:
    >
    > I am having difficulty in getting the Perl Interpretor to recognize
    > arguements submitted with a perl script. For example,I have a simple
    > perl script like this called temp.pl
    >
    > print "ARGV0 : $ARGV[0]\n";
    > print "ARGV1 : $ARGV[1]\n";
    > print "ARGV2 : $ARGV[2]\n";
    >
    > If I run the script as 'temp.pl A B C',I get the following output:
    > ARGV0 :
    > ARGV1 :
    > ARGV2 :
    >
    > If I run the script as 'perl temp.pl A B C', the arguements are then
    > recognized and I get the following output:
    > ARGV0 : A
    > ARGV1 : B
    > ARGV2 : C
    >
    > I do not understand why the difference, the perl scripts is running in
    > both cases, but in the first case no arguements seem to be recognized.
    Do you have the "shebang" line at the beginning?
    #!/usr/bin/perl

    I'm thinking that if you DON'T have that line and you
    run it without specifying "perl", then it's running
    as commands to a shell (not executing "perl") which
    -might- output what you see.
    (Or maybe not; it's just a thought. I'm on Win32, so
    can't test this theory.)

    Mike
    Michael P. Broida Guest

  5. #4

    Default Re: Perl Arguements

    Tina Mueller wrote:
    > Paul wrote:
    >
    >>I am having difficulty in getting the Perl Interpretor to recognize
    >>arguements submitted with a perl script. For example,I have a simple
    >>perl script like this called temp.pl
    >
    >
    >>print "ARGV0 : $ARGV[0]\n";
    >>print "ARGV1 : $ARGV[1]\n";
    >>print "ARGV2 : $ARGV[2]\n";
    >
    >
    >>If I run the script as 'temp.pl A B C',I get the following output:
    >>ARGV0 :
    >>ARGV1 :
    >>ARGV2 :
    >
    >
    > which operating sytem, which perl version?
    I suspected Windows but Win2K + cmd.exe:

    D:\Snippets>perl arg.pl foo bar
    foo
    bar

    D:\Snippets>arg.pl foo bar
    foo
    bar

    D:\Snippets>type arg.pl

    print join("\n", @ARGV), "\n";

    D:\Snippets>perl -v

    This is perl, v5.8.0 built for MSWin32-x86-multi-thread
    (with 1 registered patch, see perl -V for more detail)
    [snip]

    --
    Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
    virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
    John web site hints: [url]http://johnbokma.com/websitedesign/[/url]

    John Bokma Guest

  6. #5

    Default Re: Perl Arguements

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:
    >
    > Do you have the "shebang" line at the beginning?
    > #!/usr/bin/perl
    >
    > I'm thinking that if you DON'T have that line and you
    > run it without specifying "perl", then it's running
    > as commands to a shell (not executing "perl") which
    > -might- output what you see.
    My shell, bash, says "print: command not found" or some such.
    > (Or maybe not; it's just a thought. I'm on Win32, so
    > can't test this theory.)
    Why not? Doesn't Win32 have a command shell?

    - --keith

    - --
    [email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.0.6 (GNU/Linux)
    Comment: For info see [url]http://www.gnupg.org[/url]

    iEYEARECAAYFAj9dOQIACgkQhVcNCxZ5ID+m3ACfVtGQzjZ6IH J5splaDuHNyKG4
    lg0AnA0gf0WXJOFYzQ5LAid07XQYfSZL
    =qpKN
    -----END PGP SIGNATURE-----
    Keith Keller Guest

  7. #6

    Default Re: Perl Arguements

    On Mon, 8 Sep 2003 19:20:51 -0700,
    Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us> wrote:
    >
    > On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:
    >>
    >> Do you have the "shebang" line at the beginning?
    >> #!/usr/bin/perl
    >>
    >> I'm thinking that if you DON'T have that line and you
    >> run it without specifying "perl", then it's running
    >> as commands to a shell (not executing "perl") which
    >> -might- output what you see.
    >
    > My shell, bash, says "print: command not found" or some such.
    Korn shell has a print command, and it is a reasonably popular shell.
    It does say "-might-" after all.
    >
    >> (Or maybe not; it's just a thought. I'm on Win32, so
    >> can't test this theory.)
    >
    > Why not? Doesn't Win32 have a command shell?
    Not one that will execute files with arbitrary names. And clearly testing
    such a thing would be pointless since the OP isn't using the a windows
    command shell (since it won't produce the behaviour described).

    --
    Sam Holden

    Sam Holden Guest

  8. #7

    Default Re: Perl Arguements

    Keith Keller wrote:
    > On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:
    [snip]
    >> (Or maybe not; it's just a thought. I'm on Win32, so
    >> can't test this theory.)
    >
    >
    > Why not? Doesn't Win32 have a command shell?
    It has, but .pl is associated with perl so even without the she bang a
    ..pl script is executed as perl.

    without an extension:

    (1)

    D:\Snippets>arg hello world
    'arg' is not recognized as an internal or external command,
    operable program or batch file.

    and with .bat (silly)

    (2)

    D:\Snippets>arg hello world

    D:\Snippets>print join("\n", @ARGV), "\n";
    Can't find file join(\n,
    Can't find file @ARGV),
    Can't find file \n;

    With a proper she-bang and without an extension associated with perl.exe
    I expect (1).

    And for those who really want the same experience on Windows:
    [url]http://www.cygwin.com/[/url]

    > - --keith
    >
    > - --
    ^ please use the appropriate sig separator which is -- followed by one
    space. This means that most news readers automatically can remove the 12
    (not counting the sig sep) lines which includes the PGP signature. Thanks.

    --
    Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
    virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
    John web site hints: [url]http://johnbokma.com/websitedesign/[/url]

    John Bokma Guest

  9. #8

    Default Re: Perl Arguements

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On 2003-09-09, John Bokma <postmaster@castleamber.com> wrote:
    >
    > It has, but .pl is associated with perl so even without the she bang a
    > .pl script is executed as perl.
    >
    > without an extension:
    >
    > (1)
    >
    > D:\Snippets>arg hello world
    > 'arg' is not recognized as an internal or external command,
    > operable program or batch file.
    [snip]

    Both you and Sam make good points--though I think Sam's
    is slightly more valid, since neither your nor my error
    messages look like the OPs. I don't have ksh available,
    so I can't test whether that would produce the aberrant
    behaviour the OP had.
    > ^ please use the appropriate sig separator which is -- followed by one
    > space. This means that most news readers automatically can remove the 12
    > (not counting the sig sep) lines which includes the PGP signature. Thanks.
    Well, I have made a conscious decision to not use the switch
    to gpg that preserves the "-- " delimiter; according to the
    man page it causes some problems with spaces. I apologize
    for this nonstandard behaviour. Some newsreaders (like slrn)
    can strip this nonstandard sig delimiter.

    - --
    [email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.0.6 (GNU/Linux)
    Comment: For info see [url]http://www.gnupg.org[/url]

    iEYEARECAAYFAj9dVkQACgkQhVcNCxZ5ID8ZMACcD4S40O4Luo yMXfaWa94bkwAd
    OSgAn0HCVu2VRv1WeUZ//lhhMAQyesWa
    =zpGZ
    -----END PGP SIGNATURE-----
    Keith Keller Guest

  10. #9

    Default Re: Perl Arguements

    Tina Mueller <usenet@expires12.2003.tinita.de> wrote in message news:<bjis87$ivcqu$1@ID-24002.news.uni-berlin.de>...
    > Paul wrote:
    > > I am having difficulty in getting the Perl Interpretor to recognize
    > > arguements submitted with a perl script. For example,I have a simple
    > > perl script like this called temp.pl
    >
    > > print "ARGV0 : $ARGV[0]\n";
    > > print "ARGV1 : $ARGV[1]\n";
    > > print "ARGV2 : $ARGV[2]\n";
    >
    > > If I run the script as 'temp.pl A B C',I get the following output:
    > > ARGV0 :
    > > ARGV1 :
    > > ARGV2 :
    >
    > which operating sytem, which perl version?
    >
    > > If I run the script as 'perl temp.pl A B C', the arguements are then
    > > recognized and I get the following output:
    > > ARGV0 : A
    > > ARGV1 : B
    > > ARGV2 : C
    >
    > > I do not understand why the difference, the perl scripts is running in
    > > both cases, but in the first case no arguements seem to be recognized.
    >
    > i don't understand the difference, either. for me it works, if
    > i call the script with ./temp.pl (if the rights are set correctly):
    >
    > $ cat temp.pl
    > #!/usr/bin/perl -w
    > use strict;
    > print "ARGV0 : $ARGV[0]\n";
    > print "ARGV1 : $ARGV[1]\n";
    > print "ARGV2 : $ARGV[2]\n";
    > $ ls -l temp.pl
    > -rwxr--r-- 1 tina users 115 Sep 8 23:27 temp.pl
    > $ temp.pl A B C
    > bash: temp.pl: command not found
    > $ ./temp.pl A B C
    > ARGV0 : A
    > ARGV1 : B
    > ARGV2 : C
    >
    > hth, tina
    Tina,

    I am running this on Win 2k, the Perl is Active State 5.2.2.0.

    Thks,
    Paul
    Paul Guest

  11. #10

    Default Re: Perl Arguements

    Keith Keller wrote:
    >
    > On 2003-09-08, Michael P. Broida <michael.p.broida@boeing.com> wrote:
    > >
    > > Do you have the "shebang" line at the beginning?
    > > #!/usr/bin/perl
    > >
    > > I'm thinking that if you DON'T have that line and you
    > > run it without specifying "perl", then it's running
    > > as commands to a shell (not executing "perl") which
    > > -might- output what you see.
    >
    > My shell, bash, says "print: command not found" or some such.
    >
    > > (Or maybe not; it's just a thought. I'm on Win32, so
    > > can't test this theory.)
    >
    > Why not? Doesn't Win32 have a command shell?
    Not one that could pay attention to the "shebang" line
    INSIDE the file.

    Here on Win2K, there is a "print" command; I could have
    tested that, BUT our network printer queue management
    system doesn't work well from the DOS (CommandPrompt)
    side.

    Mike
    Michael P. Broida Guest

  12. #11

    Default Re: Perl Arguements

    John Bokma wrote:
    >
    > And for those who really want the same experience on Windows:
    > [url]http://www.cygwin.com/[/url]
    I am interested in Cygwin, but we need to keep all of
    our systems here in pretty nearly the same configuration
    so we don't introduce problems from dependencies on a
    particular tool.

    We had problems on an older project under Solaris when
    one person decided to use "tcsh" instead of our "standard"
    csh. Some of his scripts didn't work correctly for the
    rest of us or for our customers. :) So we enforce a
    standard set of tools.

    Mike
    Michael P. Broida Guest

  13. #12

    Default Re: Perl Arguements

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1
    NotDashEscaped: You need GnuPG to verify this message

    On 2003-09-09, Paul <pecymanski@yahoo.com> wrote:
    >
    > I am running this on Win 2k, the Perl is Active State 5.2.2.0.
    Might adding a

    use warnings;

    statement be helpful?

    --keith

    --
    [email]kkeller-mmmspam@wombat.san-francisco.ca.us[/email]
    (try just my userid to email me)
    AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.0.6 (GNU/Linux)
    Comment: For info see [url]http://www.gnupg.org[/url]

    iEYEARECAAYFAj9eMDgACgkQhVcNCxZ5ID+TiQCggO79bh0IHT oJzqK+hVeGEJqh
    xTYAnR1aRHuErPZ3lYTdy2an9KNqxlPA
    =1eLw
    -----END PGP SIGNATURE-----
    Keith Keller Guest

  14. #13

    Default Re: Perl Arguements

    Michael P. Broida wrote:
    > We had problems on an older project under Solaris when
    > one person decided to use "tcsh" instead of our "standard"
    > csh. Some of his scripts didn't work correctly for the
    > rest of us or for our customers. :)
    That's what the shebang line is for.

    --
    Bart.
    Bart Lateur Guest

  15. #14

    Default Re: Perl Arguements

    Michael P. Broida wrote:
    > John Bokma wrote:
    >
    >>And for those who really want the same experience on Windows:
    >>[url]http://www.cygwin.com/[/url]
    >
    >
    > I am interested in Cygwin, but we need to keep all of
    > our systems here in pretty nearly the same configuration
    > so we don't introduce problems from dependencies on a
    > particular tool.
    So why can you use tool Perl but not tool Cygwin?

    --
    Kind regards, feel free to mail: mail(at)johnbokma.com (or reply)
    virtual home: [url]http://johnbokma.com/[/url] ICQ: 218175426
    John web site hints: [url]http://johnbokma.com/websitedesign/[/url]

    John Bokma Guest

  16. #15

    Default Re: Perl Arguements

    John Bokma wrote:
    >
    > Michael P. Broida wrote:
    >
    > > John Bokma wrote:
    > >
    > >>And for those who really want the same experience on Windows:
    > >>[url]http://www.cygwin.com/[/url]
    > >
    > >
    > > I am interested in Cygwin, but we need to keep all of
    > > our systems here in pretty nearly the same configuration
    > > so we don't introduce problems from dependencies on a
    > > particular tool.
    >
    > So why can you use tool Perl but not tool Cygwin?
    Perl has been approved. Cygwin has not.
    I don't do the approving, so I don't know their reasons.

    Mike
    Michael P. Broida Guest

  17. #16

    Default Re: Perl Arguements

    Bart Lateur wrote:
    >
    > Michael P. Broida wrote:
    >
    > > We had problems on an older project under Solaris when
    > > one person decided to use "tcsh" instead of our "standard"
    > > csh. Some of his scripts didn't work correctly for the
    > > rest of us or for our customers. :)
    >
    > That's what the shebang line is for.
    Yeah, but... (It's been 7+ years, so my recall is a bit
    spotty...)

    The problem surfaced when the user's DEFAULT shell was tcsh.
    We tracked it down to some builtin function that behaved VERY
    slightly differently in tcsh than in csh. I don't recall now
    which function it was, but that TINY difference screwed up one
    of:
    - the setup commands we required in the .login/.cshrc files
    - the actual startup scripts for the project app
    I don't recall which.

    The simple fix was to require csh for all testing/running of
    that app. NONE of our customers were "techie" enough to find
    or use tcsh themselves; it was only ONE of our developers that
    liked using it. :) He was able to use tcsh for his general
    work as long as he set his default shell to csh and opened a
    fresh csh for testing/running.

    Mike
    Michael P. Broida Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139