From: jidanni on
How can I write
print $F[4] if exists $F[4];
even simpler?
print if exists for $F[4];
print if exists $_ for $F[4];
don't work.
From: Tad McClellan on
jidanni(a)jidanni.org <jidanni(a)jidanni.org> wrote:

> How can I write
> print $F[4] if exists $F[4];
> even simpler?


Why do you want to write
print $F[4] if exists $F[4];
even simpler?


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
From: Uri Guttman on
>>>>> "j" == jidanni <jidanni(a)jidanni.org> writes:

j> How can I write
j> print $F[4] if exists $F[4];
j> even simpler?
j> print if exists for $F[4];
j> print if exists $_ for $F[4];
j> don't work.

well, exists is for checking if a key exists in a hash. you don't have
any hashes there so of course it won't work.

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
From: Frank Seitz on
Uri Guttman wrote:
>>>>>> "j" == jidanni <jidanni(a)jidanni.org> writes:
>
> j> How can I write
> j> print $F[4] if exists $F[4];
> j> even simpler?
> j> print if exists for $F[4];
> j> print if exists $_ for $F[4];
> j> don't work.
>
> well, exists is for checking if a key exists in a hash. you don't have
> any hashes there so of course it won't work.

No, exists() checks array elements, too. See perdoc -f exists.

Frank
--
Dipl.-Inform. Frank Seitz
Anwendungen f�r Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

Blog: http://www.fseitz.de/blog
XING-Profil: http://www.xing.com/profile/Frank_Seitz2
From: Uri Guttman on
>>>>> "FS" == Frank Seitz <devnull4711(a)web.de> writes:

FS> Uri Guttman wrote:
>>>>>>> "j" == jidanni <jidanni(a)jidanni.org> writes:
>>
j> How can I write
j> print $F[4] if exists $F[4];
j> even simpler?
j> print if exists for $F[4];
j> print if exists $_ for $F[4];
j> don't work.
>>
>> well, exists is for checking if a key exists in a hash. you don't have
>> any hashes there so of course it won't work.

FS> No, exists() checks array elements, too. See perdoc -f exists.

even so, it is a useless concept IMO. array elements can be never
allocated or filled with undef and there is little reason to know the
difference. this is unlike knowing if a key exists regardless of its
value being set with undef or never being set. exists was changed to
support arrays because of pseudohashes which now are obsolete and
removed from perl. maybe they should remove the array side of exists
too.

uri

--
Uri Guttman ------ uri(a)stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------