I have an entry that is basically identical to the one found here:
(defun perl-boilerplate ()
(if (not (file-exists-p (buffer-file-name (current-buffer))))
(cond
((string-match "\.pl$" buffer-file-name)
(insert
"#!/usr/local/bin/perl\nuse warnings;\nuse strict;\n"))
((string-match "\\([^/]*\\)\.pm$" buffer-file-name)
(insert
(concat "package " (match-string 1 buffer-file-name)
";\n\nuse warnings;\nuse strict;\n\n1;\n"))
(backward-char 4)))))
(add-hook 'cperl-mode-hook 'perl-boilerplate)
...this all worked fine when I was using 22.3 on OS X. I just updated to 24.1, and now, whenever I create a new .pl file, the boilerplate inserts twice. My .emacs file didn't change, so I'm wondering what causes this: is the hook being applied twice? (Didn't think that could happen.)
Anyone encounter the same phenomenon, or can tell me how to fix this?
Also
Here's what happens when I start a module. Note how the second instance is added before the first one finishes--i.e., before it adds the closing '1;' line.
package Foo;
use warnings;
use strict;
# $Id$
package Foo;
use warnings;
use strict;
# $Id$
1;
1;
Update
It appears to be a difference in the cperl-mode.el file that shipped with 22.3 and 24.1, although I don't know exactly where. (The diff is 1,124 lines.) But swapping out the old and new files (and removing the compiled .elc file) returned the behavior to what I wanted.
add-hook
line?