Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-12 Thread Dave K
Sophia, et al > If you know in advance the array index then use splice. If you know only the value you want to remove (and you like map...): #/usr/bin/perl -w use strict; my %compilers = ( system1 => ['compiler_a'], system2 => ['compiler_b', 'compiler_c','compiler_d'], system3 => ['compiler_e'],

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-11 Thread Randal L. Schwartz
> "John" == John W Krahn <[EMAIL PROTECTED]> writes: John> From the foreach loop it looks like you want to remove the last John> occurrence of $del_name from @pro_list. You could also do it like this: John> foreach ( reverse 0 .. $#pro_list ) { John> if ( $pro_list[$_] eq $del_name ) { J

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-11 Thread John W. Krahn
Ebaad Ahmed wrote: > > Just used the following code to delete a specific value from an array, populated > from text read from file. Please let me know if i can be of any help. > sub doDeleteProvider { > my $cgi = shift; > my $counter = 0; > my $index; > my $del_name = $cgi->param("names"); >

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-11 Thread Ebaad Ahmed
Just used the following code to delete a specific value from an array, populated from text read from file. Please let me know if i can be of any help. sub doDeleteProvider { my $cgi = shift; my $counter = 0; my $index; my $del_name = $cgi->param("names"); my $TITLE = "Nighthawk Database"; fo

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-10 Thread Tim Musson
Hey Sophia, My MUA believes you used to write the following on Thursday, January 9, 2003 at 6:48:42 PM. SC> I am not sure how to delete a specific value from a hash whose SC> keys contains multiple values. SC> Could anyone advice, please? Does this help? perldoc -q delete -- Tim Mu

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-10 Thread John W. Krahn
Sophia Corwell wrote: > > Sorry about that... > > Here is an example: > > Here is what my hash looks like: > > %compilers = ( >system1 => ['compiler_a'], >system2 => ['compiler_b', > 'compiler_c','compiler_d'], >system3 => ['compiler_e'], > ); > > Now, if I want to delete just the

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-09 Thread Wiggins d'Anconia
Thanks for the example :-). You want either 'delete' or 'splice' Depending on whether you want the indexes to be shifted down, see perldoc -f delete and perldoc -f splice. "Deleting an array element effectively returns that position of the array to its initial, uninitialized state. Subsequent

RE: Removing a specific value from a hash whose keys contains multiple values

2003-01-09 Thread david
Sophia Corwell wrote: > Sorry about that... > > Here is an example: > > Here is what my hash looks like: > > %compilers = ( >system1 => ['compiler_a'], >system2 => ['compiler_b', > 'compiler_c','compiler_d'], >system3 => ['compiler_e'], > ); > > Now, if I want to delete just the 'c

Re: Removing a specific value from a hash whose keys contains multiple values

2003-01-09 Thread Wiggins d'Anconia
I am not sure I understand you correctly. Are you referring to a hash which may have a list of values stored with a particular key? Keys by the nature of a hash must be unique, so the hash is changed/deleted from in the same way regardless. I also didn't understand if you meant clearing the v

RE: Removing a specific value from a hash whose keys contains multiple values

2003-01-09 Thread Sophia Corwell
Sorry about that... Here is an example: Here is what my hash looks like: %compilers = ( system1 => ['compiler_a'], system2 => ['compiler_b', 'compiler_c','compiler_d'], system3 => ['compiler_e'], ); Now, if I want to delete just the 'compiler_c' value from the system2 key, can I use th