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

Solution

JEEZ! Sometimes it's too easy. ..


Original Question

hi

@work I'm bound to Win7 and sometimes when posting here I use cmd.exe for a little demo and try to copy it into the textarea

Unfortunately (unlike with a linux x terminal) the newlines get totally messed up

D:\Users\lanx>perl -MO=Deparse,-p,-x10 -e"sub {return 1 and 0 }"sub { + + ((return 1) and 0); + } + ;

instead of

D:\Users\lanx>perl -MO=Deparse,-p -e"sub { return 1 and 0 }" sub { ((return 1) and 0); } ; -e syntax OK
today - I don't know how - I was once able to do it without needing to manually post-process the code.

Any hints how to do it?

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

Replies are listed 'Best First'.
Re: [SOLVED] copying multiline code from cmd.exe with reasonable newlines
by KurtZ (Friar) on Jun 02, 2017 at 22:39 UTC
    Pardon my ignorance, but why would you even use <shift enter>, what is the benefit?

    A puzzled Linux user

      Well I understand your bewilderment better than I understand cmd.exe, but let me try: ;-)

      First of all copying is totally different to a xterm.

      In xterm you have a one dimensional copy, the complete lines between start and end-mark are copied and no newlines are included between automatically wrapped-over lines.

      In cmd.exe you have only (AFAIK) a rectangular copy. So if you want to copy a command which was wrapped over you need to start your selection to the very left and span to the right edge. And if you do [ENTER] instead of [SHIFT ENTER] you'd get newlines included at every right end, even if it was an automatic wrap in the middle of a word.

      like

      D:\Users\lanx>perl -e "$_='x';print;print;print;print;print;print;prin +t;print;print;print;print;print;print;pri nt;print" xxxxxxxxxxxxxxx

      Of course you can't really copy long commands with random newlines and expect to execute them right away.

      That's why you quickly get into the habit to use [SHIFT ENTER] and no newlines are included.

      D:\Users\lanx>perl -e "$_='x';print;print;print;print;print;print;prin +t;print;print;print;print;print;print;print;print"

      Colleagues showed me once [SHIFT ENTER] and only [SHIFT ENTER] and I stuck with this.

      cmd.exe is - from what I know - not very short cut friendly.

      You need to mix mouse and and keyboard actions and are happy for any help.

      I suppose power-shell is better in this respect, I'll try it out one day.

      HTH explaining the confusion a bit! :)

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

      PS: in hindsight it seems very off-toppic, but I wasn't sure if some HTML voodoo was interfering here.