http://www.perlmonks.org?node_id=836539

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

I recently bought and read Perl Best Practices. Generally my thoughts are that the book breaks down as follows:

15% of the book is clearly good and could by used by anyone without even needing to read the book, by just enforcing a subset of Perl::Critic.

5% of the book concerns inside-outside classes. While the concept is sort of beautiful, I don't think I want to even so much as start a flame war on that particular subject let alone actually use them.

The remaining 80% of the book probably does make perl better, more maintainable and more comprehensible BUT only to people who have read the book! A case in point would be extended regular expressions which I think are really scary if you just dived into the perl man page.

Anyway I was thankful to him that I could at last enforce a policy on indenting - until I needed to write a Makefile. Now all the tabs in the Makefile are spaces and its not really a Makefile any more. I suppose the solutions are to either use a different editor for Makefiles or to load a special config for Makefiles.

Replies are listed 'Best First'.
Re: Damian ate my Makefile
by assemble (Friar) on Apr 23, 2010 at 17:57 UTC
    I use the following line in my .vimrc to fix Make files:
    "Fix Make files: autocmd FileType make set noexpandtab
    Should fix you right up!
Re: Damian ate my Makefile
by MidLifeXis (Monsignor) on Apr 23, 2010 at 16:57 UTC

    To enforce a policy for perl source files on a make source file is not a good, umm, policy.

    Use the right tool for the job. Emacs can set rules for indentation, syntax, etc based on the type of file. I believe that vi also allows you to do that. Do not run perltidy on your makefile, run maketidy (is there such a beast?). Same as you would not run htmltidy, lint, or other inappropriate code cleaners on your perl file.

    My wife is walking for a cure for MS. Please consider supporting her.

Re: Damian ate my Makefile
by JavaFan (Canon) on Apr 23, 2010 at 15:53 UTC
    Hmmm, Damian uses vi (or a modern imposter), doesn't he? So, I guess you copied some vi macros and/or settings from him that turned tabs into space.

    Next time, if you really want a tab, enter it as ^V^I (control-V control-I). That should bypass any macros written by someone who isn't an evil genius.

    Oh, wait. You said Damian. He is an evil genius.

      Thanks. I'll give that a go.