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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts

    getting cgi to delete

    i am making a sorta petition/penpal type cgi thing,
    in my script i have
    foreach $key (sort(keys %input)) #we adding sorting
    {
    $key =~ s/\d\d\_//; #we remove numerals and _
    print PROFILE_OUTPUT "$key : $input{$key}";
    print PROFILE_OUTPUT "\n";
    }

    so for each entry i do 01_yadda, 02_yadda etc. etc. etc.
    but it works out in the right order except ihave no info.. wierd?
    now, i tried to fix this by in the html form thing instead of doing 01_yadda i did 01yadda.... by doing this it has the info but the 01 is still there so it would disply this for example:
    01Yadda : blahblah

    how can i fix this OR can someone please tell me how to change the above script to ONLY delete the numerals BUT still keep the data.. thanks

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    the Netherlands
    Posts
    215
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this one:

    $key =~ s/\d*//sg;

    This will remove any digit from $key

    Mzzl, Chris

  • #3
    New Coder
    Join Date
    Sep 2002
    Location
    Up North (UK)
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    reubenb,

    I think that your problem is that you are breaking your hash key. The line
    Code:
    $key =~ s/\d\d\_//;
    modifies the scalar $key and hence is nolonger the key into your hash!

    You need to copy the key to another scalar:
    Code:
    $reference = $key;
    $reference =~ s/\d\d\_//;
    print PROFILE_OUTPUT "$reference : $input{$key}";
    Hope this helps.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts

    RE:

    thanks guys so much!
    your the greatest!!!!! ))))))))))))))))


  •  

    Posting Permissions

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