develooper Front page | perl.beginners | Postings from March 2002

RE: Array question...

Thread Previous | Thread Next
John Edwards
March 28, 2002 09:04
RE: Array question...
Message ID:

if (defined @array) {
    # do something
} else {
    # It's not been created, do something else



-----Original Message-----
From: Michael D. Risser [] 
Sent: 28 March 2002 13:55
Subject: Array question...

OK here's the problem:

I have an array that may or may not have been assigned to, if it has been 
assigned to I need to do one thing, otherwise I need to do something else.

I've tried many variations, but I'm having trouble determining if it has
assigned to.

if(undef @myArray) {
    # Do thing1
} elsif(!undef @myArray) {
    # Do thing2


if ($myArray[0] ne "") {
    # thing1
} else {
    # thing2

as well as a few other variations. Printing out the array BEFORE the if
shows nothing in the array, yet it does thing1.

After trying many different methods, I am totally lost, please help me!


To unsubscribe, e-mail:
For additional commands, e-mail:

This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About