
ad65
Deleted
May 19, 2001, 6:29 AM
Post #1 of 8
(848 views)
|
|
Converting strings
|
Can't Post
|
|
Hi, i've got a string $news, which is what I fill in on a form page. Each time it's submitted, it creates a page according to the first letter of $news, and subsequent submittions starting with the same letter are added to that page. So I have links to # A B C D E etc... The # page is 0.html The problem is, say $news starts with a 1, or 2, 3 etc it isn't going to show up on the # page(0.html). Therefore, IF $news starts with a number, how can I add a 0 to the start of $news, in other words converting it to 0$news for the rest of the script. This would mean the entry '1000 people killed by explosive fart gas' would go to '01000 people etc'... And still, if it was 'Lots of people killed etc'... then it wouldn't affect it. Any ideas? Second question is, if someone can tell me how to do that first one, how do I strip the 0 off the start and make another string: Something like $newswo = $news without a leading 0 So in the end I will have $news, which is 0$news if it started with a number, and $newswo, which is 0$news but without the zero. Deary me..I don't know how to explain it further than that. Any other suggestions as to how I can get around this problem are welcome, it doesn't necessarily have to be this way of doing things. Third question - How do I get the form to recognise spaces inbetween lines, instead of just shoving all the text together with single spaces? Here's the accept form data stuff: if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $FORM{$name} = $value; } So I enter this With Gaps And it comes out 'So I enter this With Gaps', when I want it with the spaces inbetween and new lines. Anyone that can - please help. Thanx
(This post was edited by ad65 on May 19, 2001, 7:04 AM)
|