in reply to Some automation on Perlscripts?

Hello,

I like the lazy part, but I also like order and backups. For this reason I have a generic file (newscript.pl) with the following default code:
#!/usr/bin/perl -w ####################### # set Modules to Use; ####################### use strict; use warnings; use CGI qw(:standard); ####################### # Establish variables, arrays, ect. ####################### # do some stuff here ####################### # Begin main body ####################### #do more stuff here ####################### # Functions & Subroutines ####################### #do the detailed work here

This file is stored on my thumbdrive and I use Notepad++ for all my editing. I do not use VI unless I have to. I edit the files locally on my laptop/pc and SCP/SFTP the files as they are edited. This allows me to get the "pretty colors" in the editor helping me know what is a variable, operator, modules, etc. but also ensures that I have a backup copy of all my data should there be a server failure with no data recovery available (it has happened). I do try and keep a simular if not the exact directory structure on the thumbdrive to help in restoring the files if need be.

Just my $0.02....Thanks for your time.

Replies are listed 'Best First'.
Re^2: Some automation on Perlscripts?
by matze77 (Friar) on Dec 04, 2008 at 21:24 UTC

    sometimes the simple approach is the best. I like your idea of a file newscript.pl. it is easy to use ":w newfilename.pl" in vi. Unfortunately there is no notepad++ in my Debian repositories (on windows machines i like notepad++).
    But i am fine with vi this helps me too: .vimrc for perl programmers


    Thanks for this great tip.
    MH

      Do you run vim in vi-compatible mode or im vim-mode?

      you can configure your vim, so it reads from a template file if you create a new .pl file

      .vimrc:
      if has("autocmd") " load template file for new file and jump to line # autocmd BufNewFile *.pl r ~/.vim/templates/pl | 1d | 5 endif

      if vim opens a non-existant file (filename ending with ".pl"),
      it inserts the content of file "~/.vim/templates/pl" after the current line
      as we opened a new buffer, the current line was 1; that is now empty and is to be deleted
      as a last action the cursor is positioned in line 5

      (please note, that the pipe is the command separator in vim)

      ~/.vim/templates/pl:
      #!/usr/bin/perl use strict; use warnings; #> global variables (the less, the better) #> ------------------------------------------------------------------- +------- #> sub routines #> ------------------------------------------------------------------- +------- # main script #> ------------------------------------------------------------------- +------- __END__

      See :help autocmd in vim for more details of that feature.
      I think you can even configure it so it adjusts the file permissions on open/save/whatever....