全部博文(221)
分类:
2008-10-29 18:47:42
There is a default perl-mode for Emacs. However, there is a better one hidden within Emacs. The following lisp statements will activate cperl-mode.
;; Use cperl-mode instead of the default perl-mode
(add-to-list 'auto-mode-alist '("\\.\\([pP][Llm]\\|al\\)\\'" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("perl5" . cperl-mode))
(add-to-list 'interpreter-mode-alist '("miniperl" . cperl-mode))
Since I do not like the default indentations, I have the followings:
(add-hook 'cperl-mode-hook 'n-cperl-mode-hook t)
(defun n-cperl-mode-hook ()
(setq cperl-indent-level 4)
(setq cperl-continued-statement-offset 0)
(setq cperl-extra-newline-before-brace t)
(set-face-background 'cperl-array-face "wheat")
(set-face-background 'cperl-hash-face "wheat")
)
If you have perl installed on your computer, you may debug a perl script by simply typing "alt-x perldb" "perl -d myscript.pl". Once the command is entered, you will see 2 buffers in Emacs, the top buffer is the debugger, the bottom buffer is your perl script.
If you have ever tried to use ActiveState Perl in a Cygwin Bash shell, you will find that only the commands of the following formats can be run successfully.
On the other hand, the following formats will give you a problem complaining the perl script specified cannot be found.
This is because of the fact that ActiveState Perl program cannot understand Cygwin's mount drives.
There is a solution by to allow users to run ActiveState Perl in Cygwin Bash shell.
My solution is to make a C () executable that will convert the Cygwin path to Windows path before invoking the ActiveState Perl. You may have to change the path of ActiveState perl.exe in perlproxy.c according to your installation.
Now your Perl scripts should have #!/usr/local/bin/perl as the first line for things to work properly. The only side effect that I have seen so far is that you cannot type /usr/local/bin/perl in a shell to run the Perl program interactively. You will have to specify the actual path of the ActiveState Perl (for example, c:/programs/perl/bin/perl) in this case.