![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl Hash | Harikrishna | Shell Programming and Scripting | 1 | 06-04-2008 07:03 AM |
| Perl Hash | Harikrishna | Shell Programming and Scripting | 1 | 06-02-2008 11:45 PM |
| Hash in perl | Harikrishna | Shell Programming and Scripting | 1 | 06-02-2008 04:00 AM |
| perl array question from going through hash | hankooknara | Shell Programming and Scripting | 2 | 07-29-2007 09:53 PM |
| perl hash question | hankooknara | Shell Programming and Scripting | 3 | 07-28-2007 01:31 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Hash Question in Perl
Learning Perl here, so bear with me... Have a hash that i need to delete the entry out of and am having problems doing that. Basically, I need to delete all entries from the hash that have values over 5,000,000. What I am trying to do is to find each entry and delete it. Does not work - I have made many changes but either the program will not compile or the hash entries are still there
Can gurus help? #!/usr/bin/perl %messages = qw (1 342 2 4567 3 5999876 4 5768); foreach $value (values (%messages)) > 5000000 { delete $value.... #this is the line } print %messages, "\n"; |
|
|||||
|
Quote:
Ha!Ha!Ha!Ha! I make myself laugh. |
|
||||
|
example:
delete those <=5 Code:
%hash=(a,1,b,2,c,3,d,5,e,9,f,10,u,15);
foreach $key (keys %hash){
delete($hash{$key}) if $hash{$key}<=5;
}
foreach $key (keys %hash){
print $key,"-->",$hash{$key},"\n";
}
|
|
||||
|
Quote:
Does sorting here makes it a better solution, unless its an array and we are sure of the index, sorting a hash will not help us to escape from scannig each and every element of the hash. so, basically I mean - even if you are sorting, you have to scan through each and every element of the hash. I feel, sorting is not needed here ![]() |
|
||||
|
Quote:
12-28-2001 <----------- Even a thread one/two months old is pushing it, but 7+ years is beyond ridiculous. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|