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

Discussion in 'Perl Misc' started by i5513, Oct 6, 2003.

  1. i5513

    i5513 Guest

    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!
     
    i5513, Oct 6, 2003
    #1
    1. Advertising

  2. i5513 <> wrote:
    > 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


    --
    Glenn Jackman
    NCF Sysadmin
     
    Glenn Jackman, Oct 6, 2003
    #2
    1. Advertising

  3. i5513

    i5513 Guest

    Glenn Jackman <> wrote in message news:<>...
    > i5513 <> wrote:
    > > 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


    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)).
     
    i5513, Oct 6, 2003
    #3
  4. i5513

    Helgi Briem Guest

    On 6 Oct 2003 10:40:49 -0700, (i5513) wrote:

    >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
     
    Helgi Briem, Oct 7, 2003
    #4
  5. Helgi Briem <> wrote:
    > On 6 Oct 2003 10:40:49 -0700, (i5513) wrote:
    >
    >>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:



    Five , m'lord.


    > \n line feed
    > \r carriage return
    > \t tab
    > space



    you forgot form feed \f


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Oct 7, 2003
    #5
  6. Re: Strange behaviour with '\r' character [[ sorry my other postwas wrong typed ]]

    Helgi Briem <> wrote:

    > On 6 Oct 2003 10:40:49 -0700, (i5513) wrote:
    >
    >>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:


    No, that's 5 different characters:

    > \n line feed
    > \r carriage return
    > \t tab
    > space


    \f form feed

    Cheers

    Jens
    --
    (Intentionally left blank.)
     
    Jens M. Felderhoff, Oct 7, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ersin Gençtürk
    Replies:
    1
    Views:
    3,494
    Ersin Gençtürk
    Oct 6, 2004
  2. Replies:
    10
    Views:
    457
    Marcus Kwok
    Mar 28, 2006
  3. Yingjie Lan
    Replies:
    4
    Views:
    306
    John Nagle
    Jan 29, 2010
  4. i5513
    Replies:
    4
    Views:
    126
    Tad McClellan
    Oct 7, 2003
  5. Michal Jankowski
    Replies:
    0
    Views:
    154
    Michal Jankowski
    Apr 29, 2011
Loading...

Share This Page