scalar context for testing arguments

Discussion in 'Perl Misc' started by fvdmarkt@gmail.com, Mar 6, 2008.

  1. Guest

    Hi,


    Is this the right way to test for existence of arguments?

    if (@ARGV > 0) {
    }

    or should I use the index of the last argument?

    if ($#ARGV >= 0) {
    }


    Who has a better suggestion?
    , Mar 6, 2008
    #1
    1. Advertising

  2. Guest

    wrote:
    > Hi,
    >
    > Is this the right way to test for existence of arguments?
    >
    > if (@ARGV > 0) {
    > }
    >
    > or should I use the index of the last argument?
    >
    > if ($#ARGV >= 0) {
    > }
    >
    > Who has a better suggestion?


    I prefer:

    if (@ARGV) {

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    The costs of publication of this article were defrayed in part by the
    payment of page charges. This article must therefore be hereby marked
    advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
    this fact.
    , Mar 6, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Dowson
    Replies:
    1
    Views:
    301
    Chris Dollin
    May 1, 2007
  2. Clint Olsen
    Replies:
    6
    Views:
    342
    Jeff 'japhy' Pinyan
    Nov 13, 2003
  3. dutone
    Replies:
    8
    Views:
    93
    dutone
    Jul 2, 2004
  4. Stuart Kendrick

    how to force scalar context

    Stuart Kendrick, Jul 12, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    154
    Stuart Kendrick
    Jul 13, 2004
  5. Mark

    Replace scalar in another scalar

    Mark, Jan 27, 2005, in forum: Perl Misc
    Replies:
    4
    Views:
    154
    Arndt Jonasson
    Jan 27, 2005
Loading...

Share This Page