Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > undefine @array

Reply
Thread Tools

undefine @array

 
 
George Mpouras
Guest
Posts: n/a
 
      08-22-2012
I want to delete an array completly.

use strict; use warnings; my
@array=qw/a b c/;
@array=();
undef @array;
print @array;

I expect a warning like "Global symbol "@array" requires explicit..." but it
did not compaint

 
Reply With Quote
 
 
 
 
George Mpouras
Guest
Posts: n/a
 
      08-22-2012
yes I want to clear symbol @array completly but at the same scope
 
Reply With Quote
 
 
 
 
Tim McDaniel
Guest
Posts: n/a
 
      08-22-2012
George Mpouras <(E-Mail Removed)> wrote:
> I expect a warning like "Global symbol "@array" requires explicit..."
> but it did not compaint


but later
>yes I want to clear symbol @array completly but at the same scope


These goals are not consistent. As Eli explained, that is not
possible in Perl.

If you clear an array, like
my @array;
...
@array = ();
or
my @array;
...
undef @array;
that sets @array to have zero elements, but @array still exists as a
variable and you will not get a message for using @array later.

"Global symbol ... requires explicit" is an error, not a warning, so
far as I know. The only way to get that error is to declare @array in
a scope that ends, like
{
my @array = (12, 14, 16);
...
}

--
Tim McDaniel, http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
2.0 runtime javascript error - WebForm_PostBackOptions is undefine =?Utf-8?B?UmljaA==?= ASP .Net 15 09-14-2011 09:04 AM
Undefine a function from header file T Ryi C Programming 6 03-25-2010 01:36 PM
undefine for functions Pietro Cerutti C Programming 8 08-31-2007 01:25 AM
STL: assistance with error - class undefine type Alden Pierre C++ 7 05-20-2006 06:21 AM
undefine all macros from a file Rafal 'Raf256' Maj C++ 1 01-19-2005 05:31 AM



Advertisments