Click here to get back home

scalar context for testing arguments

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
scalar context for testing arguments fvdmarkt 03-06-2008
Posted by fvdmarkt on March 6, 2008, 11:10 am
Please log in for more thread options

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?


Posted by xhoster on March 6, 2008, 11:16 am
Please log in for more thread options
fvdmarkt@gmail.com 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.

Similar ThreadsPosted
How to pass an array and scalar as arguments to a subroutine/ June 28, 2006, 12:16 pm
how to force scalar context July 12, 2004, 12:07 pm
list vs scalar context for localtime? October 25, 2004, 3:48 pm
file glob in scalar context March 29, 2006, 10:56 am
WHY are args for sprintf in scalar context? October 31, 2007, 9:25 am
substr forces scalar context with array argument November 29, 2005, 7:18 am
Why isn't void context a 'real' context December 11, 2007, 4:15 pm
List context versus list context June 21, 2006, 4:18 pm
Replace scalar in another scalar January 27, 2005, 3:21 pm
getting arguments July 28, 2007, 4:01 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap