Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • There is some improvement to be made.
    /2CR         # (CR is return) search for the 2 (or some other way to get there)
    r1kr2        # change 2->1, up, change 1->2
    ddp          # delete 1'st line, append 1'st line after 2'nd
    The "r" is useful to change one character ("R" will overwrite a bunch of chars, it's like insert mode but overwrites).

    The "ddp" switches the current line with the next. It is a variant on the very useful (especially for dyslexics) "xp" which swaps the current char with the next.

    Actually, though, I would normally just swap the second args, instead of swapping the first args and then swapping the lines. Go to the 2'nd arg on the 1'st line (/\$CR), delete it (de), down to the start of the 2'nd arg on the 2'nd line (j), prepend the deleted arg (P), back to the start of the 2'nd 2'nd arg (l), delete it (dt'), up to the 2'nd arg pos in the 1'st line (kh), prepend it back (P).

    • I found one aspect of vi that prepared me well for Larry's view of perl (that writing pidgin perl is a great way to start and should be tolerated, nay encouraged).

      I found that my initial use of vi was adequate, but that every 6 months or a year I would read through the vi manual and pick a few more useful idioms and add them to the set that I knew well enough to use without thinking. After a few years of this, my vi repertoire was large enough that most of the new idioms I tried to learn were not useful o