newbie00 has asked for the wisdom of the Perl Monks concerning the following question:

I was looking at a script and I do not understand what s/%0D%0A/ / means? I looked in Perl reference books under regular expressions and pattern matching and did not find anything similar. I also looked in the code and did not see a prior reference to this. Does anyone know what it means? If so, where can I find additional info on this or what should I look for in the index of a reference manual?

Thanx. --newbie00

  • Comment on Does anyone know what s/%0D%0A/ / means?

Replies are listed 'Best First'.
Re: Does anyone know what s/%0D%0A/ / means?
by Juerd (Abbot) on Jan 25, 2002 at 03:04 UTC
    It removes the literal string %0D%0A. (More correct: it substitutes the forementioned string with nothing)

    Please note that %0D is not CR until it is, and the same goes for %0A (LF). Some have replied this s/// removes CRLF sequences - that is NOT true! (It doesn't even remove all uri-encoded CRLF sequences: that would need /i)

    2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Re: Does anyone know what s/%0D%0A/ / means?
by Anonymous Monk on Jan 25, 2002 at 00:47 UTC
    If I would tell you that %0D%0A (usually) translates into \n\r, would that make more sense to you? It is only the hexadecimal respresentations, most likely encoded in an URL (you are looking at some kind of CGI script ).
Re: Does anyone know what s/%0D%0A/ / means?
by tradez (Pilgrim) on Jan 25, 2002 at 00:36 UTC
    Real quick RTFM note, on your command line type
    [rookie@scaryUnixTerminal~]$ perldoc perlre
    To answer your question though, it means to traverse the string, find a carriage return followed immediately by a linefeed and get rid of them.
    Tradez
Re: Does anyone know what s/%0D%0A/ / means?
by dvergin (Monsignor) on Jan 25, 2002 at 00:46 UTC
    It means to find an encoded Carriage Return followed immediately by an encoded Linefeed and replace them with nothing... effectively deleting those two 'entities' if they occur anywhere in the current string together and in that order.

    Update: Fixed for brain drift.