#!/usr/bin/env perl use strict; use warnings; use utf8; my $source_md = shift; my $target_tex = shift; open my $texFH, '>', $target_tex; { open my $fh, '<', 'md2tex/first.tex'; while (my $line = <$fh> ) { print $texFH $line; } close $fh; } open my $fh, '<', $source_md; while (my $line = <$fh>) { if ($line =~/^#/) { $line =~ s/# (.*)/\\section{$1}/; } print $texFH $line; } close $fh; print $texFH <<'EOF'; \nocite{*} \bibliographystyle{ipsjunsrt} \bibliography{anatofuz-bib} \end{document} EOF close $texFH;