Strange behaviour with '\r' character [[ sorry my other post was wrong typed ]]

I

i5513

Hi!. I don't understand ...

At a html page:
<form name="form1" method="POST" action="example.cgi" >
<textarea name="text"></textarea>
</form>

At a cgi script (example.cgi)
(After get parameters)
if ($FORM{"text"} =~ /^(\s|\n|\r)*$/)
{
print "<HTML>";
if ($FORM{"text"} =~ /\r/)
{
print "Hey! It is here! <BR> ";
}
if ($FORM{"text"} =~ /^(\s|\n)*$/)
{
print "Now it isn't here!";
}
print "</HTML>";
exit (1);
}

Well, When I execute (on Windows) this script with one simple return
on textarea. It gives me next result:
Hey! It is here!
Now it isn't here!

What does Perl do with '\r' character?

Thanks you!
 
G

Glenn Jackman

i5513 said:
if ($FORM{"text"} =~ /\r/)
{
print "Hey! It is here! <BR> ";
}
if ($FORM{"text"} =~ /^(\s|\n)*$/)
{
print "Now it isn't here!";
}

Well, When I execute (on Windows) this script with one simple return
on textarea. It gives me next result:
Hey! It is here!
Now it isn't here!

What does Perl do with '\r' character?

\s (whitespace) contains \r
 
I

i5513

Glenn Jackman said:
\s (whitespace) contains \r

Thanks you! I have read on perlre:
\s Match a whitespace character
But I didn't know '\r' was whitespace (I thinked about \s was( |\t)).
 
H

Helgi Briem

Thanks you! I have read on perlre:
\s Match a whitespace character
But I didn't know '\r' was whitespace (I thinked about \s was( |\t)).

\s contains 4 different kinds of white space:
\n line feed
\r carriage return
\t tab
space
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top