Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder MetalGear's Avatar
    Join Date
    Feb 2008
    Location
    Jambudvipa
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post

    Smile How to change hash value for a particular Key?

    Hello all,

    I have a query, is there any way to change value of a particular key in hash?

    Code:
    my %unique;
    $j = 1;
    $unique[$ftype[$k] = "j"
    for($i=0;$i<$length;$i++)
    {
    if(($i+1)<$length)
            {
                    if($ftype[$i] eq ($ftype[$i+1]))
                    {
                            $j++;
                            $unique{$ftype[$k]} = "$j"; ##Here I am trying to assign new value
                    }
                    if($ftype[$i] ne ($ftype[$i+1]))
                    {
                            $j = 1;
                            $unique{$ftype[$i+1]} = "$j";
                    }
            }
    }
    based on certain conditions, I am trying to edit the hash key's value,
    but it is returning 1, Which I am assigning to the key when it is created.

    Please help me,
    Thanks
    Last edited by MetalGear; 02-26-2010 at 09:08 AM.

  • #2
    New Coder MetalGear's Avatar
    Join Date
    Feb 2008
    Location
    Jambudvipa
    Posts
    56
    Thanks
    6
    Thanked 1 Time in 1 Post
    My mistake, some variable was manipulated.
    This code does work.

    please delete if required
    Quote Originally Posted by anil mundewadi View Post
    Hello all,

    I have a query, is there any way to change value of a particular key in hash?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •