RE: deleting an element from an array

2006-04-22 Thread Ankur Gupta
Johan Meskens CS3 jmcs3 scribbled on Saturday, April 22, 2006 5:26 PM: > hello > i want to delete an element from an anonymous array in a hash with: > > delete ${$alltheworlds{ $d }}[$num]; perldoc -f splice. my $deleted_element = splice(@{$alltheworlds{ $d }} , $num

Re: deleting an element from an array

2006-04-22 Thread Jaime Murillo
On Saturday 22 April 2006 17:26, Johan Meskens CS3 jmcs3 wrote: > hello Hi Johan > > > i want to delete an element from an anonymous array in a hash with: > > delete ${$alltheworlds{ $d }}[$num]; > First type the command perldoc -f delete This explains why you are receiving the results you are

deleting an element from an array

2006-04-22 Thread Johan Meskens CS3 jmcs3
hello i want to delete an element from an anonymous array in a hash with: delete ${$alltheworlds{ $d }}[$num]; now instead of being being deleted it turns out be 'undef' and my @array = ( undef, "one", "two" ); print scalar @array gives :3 so the element is only "half" deleted where is the

Re: Deleting an element from an array.

2001-10-23 Thread Etienne Marcotte
use strict; my @array=qw(a b c d e f g h); splice(@array,1,1); print "new list = @array"; will return: a c d e f g h In your mesasge you say "I know I want to remove the second value, $array[2]. How should I do this?.." but second value has [1] and not [2] :-) You can remove multiple elements

Re: Deleting an element from an array.

2001-10-23 Thread RaFaL Pocztarski
wh wrote: > This works but it can't be this easy, so tell this true beginner what's > wrong with it! I checked it with print "@array\n"; and got an error message > about an "uninitialized value in join or string" I don't know how to deal > with. > > @array = (1, 2, 3, 4, 5); > delete $array[2];

Re: Deleting an element from an array.

2001-10-22 Thread wh
Hi, This works but it can't be this easy, so tell this true beginner what's wrong with it! I checked it with print "@array\n"; and got an error message about an "uninitialized value in join or string" I don't know how to deal with. @array = (1, 2, 3, 4, 5); delete $array[2]; Wendy. "Andrew M

Re: Deleting an element from an array.

2001-10-03 Thread Randal L. Schwartz
> "Brett" == Brett W McCoy <[EMAIL PROTECTED]> writes: Brett> On Wed, 3 Oct 2001, Mason, Andrew wrote: >> Say I have an array @array = ( 1, 2, 3, 4, 5) >> >> I know I want to remove the second value, $array[2]. How should I do >> this? Brett> Take a look at the perldoc for 'split'. It doe

Re: Deleting an element from an array.

2001-10-03 Thread Jeff 'japhy' Pinyan
On Oct 3, Mason, Andrew said: >Say I have an array @array = ( 1, 2, 3, 4, 5) > >I know I want to remove the second value, $array[2]. How should I do >this? You want splice(). splice @array, $offset, $length, @replacement; In your case, $offset is 2, $length is 1, and there is no @replacemen

Re: Deleting an element from an array.

2001-10-03 Thread Brett W. McCoy
On Wed, 3 Oct 2001, Mason, Andrew wrote: > Say I have an array @array = ( 1, 2, 3, 4, 5) > > I know I want to remove the second value, $array[2]. How should I do > this? Take a look at the perldoc for 'split'. It does what you want to do. http://www.c

Deleting an element from an array.

2001-10-03 Thread Mason, Andrew
Say I have an array @array = ( 1, 2, 3, 4, 5) I know I want to remove the second value, $array[2]. How should I do this? Is it possible to issue a command that just does this for me or do I have to loop through setting $array[n]=$array[n+1] for n>which ever value I wish to remove? (I hope that