Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl problem : string functions

Data between < and > vanishes

         

kaled

11:27 am on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have code that works fine on my PC but when I upload it it fails.

It transpires that string functions such as uri_unescape (and I think chomp too) are stripping all data between the '<' and '>' characters. Literally, the data vanishes including the diamond brackets.

I've never seen or heard of anything like this before.

Perl version on the server is 5.00503

Any thoughts?

Kaled.

timster

12:50 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmm...not and expert on uri_unescape, but maybe run this regex before feeding it the string, to change the carets into character entities:

s/([<>])/'&#' . ord($1) . ';'/ge;

kaled

1:06 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I may be able to replace uri_unescape, but it's also going wrong reading data from a file - it's totally bizarre.

Kaled.

DrDoc

3:03 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like the problem lies in reading from a file... What does that particular piece of code look like?

TheWhippinpost

3:13 pm on Jun 16, 2004 (gmt 0)

10+ Year Member



DrDoc may've provided the clue as those brackets are also functions for reading/writing to file too.

kaled

4:36 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No it's not file handling. As a for instance, I tried using curly braces - worked fine. I then used test =~ s/{/</ etc. to replace braces with '<>' and the same thing happened. Text between the angle brackets (and the angle-brackets themselves) disappeared. The code worked fine on my PC.

There must be a fault in that particular perl distribution.

I'll write a short demo program and if that fails (as I'm sure it will) I'll report it and ask for a new version of Perl to be installed.

Kaled.

kaled

6:48 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm a complete idiot.

On my PC, I'm viewing text output in a console window. But I'm outputting an HTML page, and the browser is sees <some text> as an unrecognised tag and therefore doesn't display it.

Boy do I feel stupid right now! Sorry for wasting everyone's time.

Kaled.