Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^4: if (defined @arr) problem

by davorg (Chancellor)
on Dec 15, 2005 at 11:22 UTC ( [id://516924]=note: print w/replies, xml ) Need Help??


in reply to Re^3: if (defined @arr) problem
in thread if (defined @arr) problem

I'll add something : suppose the OP wanted to undef arrays in a sub . I think I would pass the array as a reference, undef it in the sub and return the reference.

In technical discussions terms have precise meanings and it's important to use them in the same way that other people do. I don't think that "undef an array" means what you think it means.

If you mean to remove all of the elements of the array, then say that. If you want to replace all of the elements with the value undef then say that. Or do you actually mean that you want to call undef @ARRAY? According to the docs that will "forget @ARRAY ever existed". Which of these do you mean?

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re^5: if (defined @arr) problem
by secret (Beadle) on Dec 15, 2005 at 13:32 UTC

      remove all of the elements of the array

    Well that would be @array = ()

      replace all of the elements with the value undef

    That could be @a = (undef) x scalar @a

    So yes , saying "undef an array" i meant  undef @a . I do think it's what the OP was meaning to do when trying to affect one single undef value to the whole array . This really sounds like undef @array.

    Now about delete for the moment i never got to use it, neither did i use exist . I gather it's because they are used mainly with objects, are they ?

    Regards,
    secret

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://516924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-04-23 23:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found