CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
delete value from the hash

 



digioleg54
User

Sep 29, 2016, 11:42 AM

Post #1 of 2 (1799 views)
delete value from the hash Can't Post

I have a hash
my %machines = (user1 => 'yogi',
user2 => 'booboo',
user3 => 'rupert',
user4 => 'teddy',
user5 => 'care',
user6 => 'winnie',
user7 => 'sooty',
user8 => 'padders',
user9 => 'polar',
user10 => 'grizzly',
user11 => 'baloo',
user12 => 'bungle',
user13 => 'fozzie',
user14 => 'huggy',
user15 => 'barnaby',
user16 => 'hair',
user17 => 'greppy');

How can I delete value, but not key?


Laurent_R
Veteran / Moderator

Sep 29, 2016, 2:34 PM

Post #2 of 2 (1794 views)
Re: [digioleg54] delete value from the hash [In reply to] Can't Post

Hi
you can't delete the value without deleting the key.

But you can set the value to an empty string or, probably better, to undef:

Code
$machines{user11} = '':

or

Code
$machines{user11} = undef:


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives