Perl hash question - TechRepublic
General discussion
December 21, 2001 at 06:05 AM
bradleyr

Perl hash question

by bradleyr . Updated 24 years, 5 months ago

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? (in case somebody is wondering, I am trying to delete messages over 5Mb from a POP3 server…i have everything else but this – the most important part)

#!/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”;

This discussion is locked

All Comments