LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-05-2010, 11:45 PM   #1
molossus
Member
 
Registered: Nov 2010
Location: US
Distribution: Ubuntu 12.04
Posts: 49

Rep: Reputation: 0
simple header for perl programs


Hi, i am trying to do something very simple like a header and a footer for my first perl programs, what iam trying to do is that when i create a file in vim: lets say hello.pl , i would like that file to have already this in its header:
#!/usr/bin/perl
and this on the footer:
print "\n";
so that i dont have to type everytime #!/usr ..... etc
i tried to do it this way but i get weird vim errors:
header is a file that contains the header and footer
$ vim hello.pl;header > hello.pl

is there another way to do it as a function in bash or some other one liner command?

apologies if what i am trying to do sounds ridiculous ,i just want to be able to create perl files in vim but with the header and footer.

thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 11-06-2010, 06:36 AM   #2
scottn
LQ Newbie
 
Registered: Jul 2010
Posts: 14

Rep: Reputation: 2
Hi.

I added this to my ~/.vimrc, and it seems to do the trick:

Code:
:map <F4> 1Gi<C-R>="#!/usr/bin/perl\n"<CR><Esc> Go<C-R>="print \"\\n\""<Esc>
Opening a file and pressing F4 will insert a first and last line:
Code:
#!/usr/bin/perl
 ---- your file
 ---- your file
print "\n"
 
2 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
perl: simple one line replacement, simple error message! pwd_pwd_omg_pwd Programming 8 11-19-2008 12:53 PM
simple regex not so simple (perl) ludeKing Programming 5 03-02-2005 02:29 AM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
need perl fuction like c #include statement for header file mrtwice Programming 5 06-19-2003 02:42 PM
simple question - can you move header and lib files from one box to another without a dewcansam Linux - Newbie 3 11-06-2001 05:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration