Ever tried outline-mode in an emacs?
It works with Perl, too. Just put this code into your
.emacs, or execute it from buffer *scratch*. Then
do M-x perl-outline-mode after you opened
the Perl code file. You can then expand and
contract subroutines (with C-c @ C-t to contract all,
C-c @ C-a to expand all,
C-c @ C-d to contract a function, C-c @ C-s to expand it).
(defun perl-outline-mode ()
"set customized outline minor mode for Perl"
(interactive)
(setq outline-regexp "sub")
(outline-minor-mode))
Update: This works even better:
(defun perl-outline-mode ()
"set customized outline minor mode for Perl"
(interactive)
(setq outline-regexp
"#!.\\|\\(pac\\)kage\\|sub\\|\\(=he\\)ad\\|\\(=po\\)d")
(outline-minor-mode))
At the end of your file. Then you can use the string # {{{ (note the
space at the end: Hash-Space-Brace-Brace-Brace-Space) to begin a fold block and # }}} (space!) to
end that block. When XEmacs loads that file all blocks will be folded
and you can usually open them with a rightclick on the fold mark. ISearch works over
the folded parts, too.
Of course this works in many more languages (examine the value of fold-top-regexp or fold-top-mark
to find the right string
leaves all unindented text visible (eg, 'use', etc. outside of subs).
Wrong:   Newline isn't a space character (at least in my tables) it's an '>' -- "end of comment" character (sigh).
the only regexp I could actually make work is "sub\\|^[^ <tab><c-J>]"where I actually ctl-q inserted the tab and newline.
Works great as advertised, but the key interface is horrid.
The menus work, but I was hunting around for some control-click
combo that would accomplish the same thing.
Is there a point and click interface for the outline functions?
UPDATE: - there is now a Foldout mode included with GNU Emacs. But also plain old Emacs outline mode works quite well and there is no need for you to set your own outline-regexp if you're using cperl-mode.