PDA

View Full Version : getting cgi to delete


reubenb
09-12-2002, 11:05 AM
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 :confused: :thumbsup:

chrisvmarle
09-12-2002, 11:58 AM
Try this one:

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

This will remove any digit from $key

Mzzl, Chris

fivesidecube
09-12-2002, 12:01 PM
reubenb,

I think that your problem is that you are breaking your hash key. The line $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:
$reference = $key;
$reference =~ s/\d\d\_//;
print PROFILE_OUTPUT "$reference : $input{$key}"; Hope this helps.

reubenb
09-12-2002, 12:40 PM
thanks guys so much!
your the greatest!!!!! :)))))))))))))))))
:thumbsup: :thumbsup: :o :o :D