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

use Perl Log In

Log In

[ Create a new account ]

mattk (7945)

mattk
  (email not shown publicly)
http://perlmonks.org/?node_id=424873

Developer for a domain registrar/web host.

Journal of mattk (7945)

Saturday September 20, 2008
12:32 PM

Indirect object notation is frowned upon

[ #37500 ]

I like to banish it in Vim, with this:

%s/\(new\) \([A-Za-z0-9:]*\)/\2->\1/gc

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.
  • \1 and \2 in the right-hand side of a search-and-replace is frowned up (specifically, it causes a warning under the warnings pragma) - instead use $1 and $2

    • Did you actually pay attention? He posted a Vim command, not a line of Perl, given away by the initial % and the /c modifier. And, err, Vim has neither $1 nor a warnings pragma.

      • Yes I read that it was for use in vim - but the only vim command I know is ":wq"

        No I didn't notice the only 2 characters that makes it not valid perl (though the leading % char could mean anything if it were sort of configuration language)

        Though, I can't imagine the OP cares, as I hope the smiley in my original subject line would communicate it as only a light-hearted poke.
        And I don't really care, as my comment shows I probably don't use vim.

        So, I guess that's a long winded (and hopefully vaguely polite) wa

  • Shouldn't that star after the "class name characters" not actually be a plus? Otherwise, I'm quite sure you'll "fix" too much. You probably still will, for example use of the word "new" in comments.