Professional Web Applications Themes

Extra carriage returns - why? - PERL Miscellaneous

John Andrews wrote: > Running perl, v5.6.1 (built for cygwin-multi) on Win2000 > From previous post in thread: perl -pe 's/NEVERFOUND/NEVERFOUND/g' < foo > bar Hmmmmmm...I was unable to duplicate your problem on Windoze 98SE with Cygwin B20 and Perl 5.6.1 (both a bit dated at this point). If I started with the Windoze line-end convention, that was maintained, and if I started with the Unix line-end convention, that was also maintained across the code you showed. -- Bob Walton...

  1. #1

    Default Re: Extra carriage returns - why?

    John Andrews wrote:
    > Running perl, v5.6.1 (built for cygwin-multi) on Win2000
    >

    From previous post in thread:

    perl -pe 's/NEVERFOUND/NEVERFOUND/g' < foo > bar

    Hmmmmmm...I was unable to duplicate your problem on Windoze 98SE with
    Cygwin B20 and Perl 5.6.1 (both a bit dated at this point). If I
    started with the Windoze line-end convention, that was maintained, and
    if I started with the Unix line-end convention, that was also maintained
    across the code you showed.

    --
    Bob Walton

    Bob Walton Guest

  2. #2

    Default Re: Extra carriage returns - why?

    [email]john.andrews1talk21.com[/email] (John Andrews) wrote in message news:<fc134cb0.0308282339.67d992e2posting.google. com>...
    > I have a text file foo. At the end of each line in foo I have
    > carriage return and newline characters, i.e. \r\n
    >
    > If I do this
    >
    > perl -pe 's/NEVERFOUND/NEVERFOUND/g' < foo > bar
    >
    > ... then bar contains exactly the same as bar, except
    > that extra carriage returns have been added, i.e. each
    > line finishes with \r\r\n . Anyone know why this happens,
    > and how I can stop it?
    >
    > Yours in puzzlement
    My guess is something is wrong with the line endings in foo ... I
    create my own foo file and ran the above one-liner without
    encountering the problem you're describing. But I have run into
    similar problems myself. Usually it was caused by a couple of things:

    1) When printing out a line in a perl program there's no need to end
    lines with a "\r\n" on a Win box. Plain old "\n" will do (\n is
    magical in Perl - it will output whatever line endings your OS may
    need). This applies only if you're creating foo with a Perl script.

    2) "Clean" the source file by opening it in your text editor, copy and
    paste everything into notepad, and from notepad copy & paste it back
    into a new doent in your text editor. Then save the file, making
    sure the save dialog uses your OS's line endings.

    If this voodoo doesn't work for you, sorry.

    These type of problems are very vexing, but usually the fault lies in
    your text editor and the way it is saving files.

    gnarred
    gnarred Guest

  3. #3

    Default Re: Extra carriage returns - why?

    Yes, you guys are all correct, I do have problems with my line
    endings (caused by files originally created on a mac, then a
    revision control server doing something 'clever' when
    files are checked out)

    Thanks
    John Andrews Guest

  4. #4

    Default Re: Extra carriage returns - why?


    "John Andrews" <john.andrews1talk21.com> wrote in message
    news:fc134cb0.0308290528.5a678e0eposting.google.c om...
    > Running perl, v5.6.1 (built for cygwin-multi) on Win2000
    Very nice, but what was your question?

    Actually, that was a retorical question, as I've deduced that you asked your
    question in your original post, but as that has expired on my newserver, I
    can not see it, hence the reason that you should properly quote yourself if
    you are following up to a post.

    Have you read the posting guidelines for this group and read any tutorials
    on using newgroups in general?


    Tintin Guest

Similar Threads

  1. CFC accessor method inserting carriage returns
    By Cory P. in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: April 6th, 03:54 PM
  2. Removing carriage returns...
    By JakeFlynn in forum Macromedia ColdFusion
    Replies: 3
    Last Post: April 5th, 08:54 PM
  3. replacing carriage returns in file
    By the real rob rone in forum Macromedia ColdFusion
    Replies: 1
    Last Post: March 17th, 05:35 PM
  4. XML, carriage returns and special characters.
    By Johnny Walker in forum Macromedia Flash
    Replies: 6
    Last Post: January 3rd, 03:00 AM
  5. replacing carriage returns?
    By yawnmoth in forum PHP Development
    Replies: 1
    Last Post: November 1st, 11:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139