"Sharat Hegde" <[EMAIL PROTECTED]> writes:
> I need to delete an element from a list (array). The
> delete function does not seem to work.
[snip]
> delete ($myList[$i]);
Check the documentation for 'delete' and 'splice'. You'll
find that delete works on hashes, splice works on arrays.
--
Mich
> -Original Message-
> From: Michael Fowler [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 2:20 PM
> To: Bob Showalter
> Cc: [EMAIL PROTECTED]
> Subject: Re: Deleting from a list
>
>
> On Fri, Dec 21, 2001 at 11:36:58AM -0500, Bob Showalter wrot
On Fri, Dec 21, 2001 at 09:36:03AM +, Sharat Hegde wrote:
> I need to delete an element from a list (array).
Array is correct. You can't delete elements from a list.
> The delete function does not seem to work. For example if I need to delete
> element number "i" from the list "myList", th
On Fri, Dec 21, 2001 at 04:09:21AM -0600, Steve Maroney wrote:
> looks like you're using [] instead of {} ... PHP instead of PERL maybe ??
>
> %myList = ("1","a","2","b");
I'm not sure if you're serious, joking, or trying to subtly provide an
alternative solution. Whichever way you've gone, you
On Fri, Dec 21, 2001 at 11:36:58AM -0500, Bob Showalter wrote:
> What version of Perl are you using? delete() for array elements
> seems to be a 5.6 feature.
>
> If you are using an earlier version, use splice().
delete and splice behave differently in certain cases; the preferred methods
are to
> -Original Message-
> From: Sharat Hegde [mailto:[EMAIL PROTECTED]]
> Sent: Friday, December 21, 2001 4:36 AM
> To: [EMAIL PROTECTED]
> Subject: Deleting from a list
>
>
> Hello,
>
> I need to delete an element from a list (array). The delete
> funct
Use splice (perldoc -f splice)
To delete array index $i
splice (@myList, $i, 1)
hth,
Sudarsan
Sharat Hegde wrote:
> Hello,
>
> I need to delete an element from a list (array). The delete function does
> not seem to work. For example if I need to delete element number "i" from
> the list "myList
worked for me :)
looks like you're using [] instead of {} ... PHP instead of PERL maybe ??
%myList = ("1","a","2","b");
print "Before: \n";
while (($key,$val) = each(%myList)) {
print "$key --> $val\n";
}
delete($myList{"1"});
print "\n\n\n After: \n";
while (($key,$val) = each(%myLis
Hello,
I need to delete an element from a list (array). The delete function does
not seem to work. For example if I need to delete element number "i" from
the list "myList", then the code
delete ($myList[$i]);
does not seem to be working. Gives a compilation error.
What is the alternative?