#!/usr/bin/perl use warnings; use strict; $| = 1; # template to illustrate using perl to generate files # in other languages such as C # in the editor, good to set filetype to c (rather than perl) my $a_file_c = ''; my $copyright = ''; $copyright =< int main( ) /* {{{3 */ { int rc; printf("Hello World!\n"); here_doc # }}} # --- # pure perl code my $key_var = 'a_key_c_var'; # next block of c-code has perl executable code inside it # the perl code is captured in $stuff and then inserted # into $a_file_c $a_file_c .=< 0) { must_do = some_more + thing; } } // end main here_doc #}}} # --- my $foo = ''; $foo = 'a_file.c'; open (OUT, ">$foo") or die "Unable to open $foo for writing:$!\n"; binmode OUT; print OUT $a_file_c; close OUT; __END__