From 1fe006e26af72f145dd9220ffdda48fd12e1111c Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Mon, 6 Dec 2021 23:31:32 -0500 Subject: [PATCH] Clarification des fonctions open() --- gtx2tex.pl | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/gtx2tex.pl b/gtx2tex.pl index de6c53f..9379053 100644 --- a/gtx2tex.pl +++ b/gtx2tex.pl @@ -83,7 +83,7 @@ do "/usr/local/lib/guitartex/language/$language.pl" or die "cannot load language $outfilename =~ s/\s/\_/g; # open output file -open ( TEX, ">$outfilename.tex" ) || die "cannot open output file"; +open ( TEX, '>', "$outfilename.tex" ) || die "cannot open output file"; # LaTeX-Header ausgeben latex_header(); @@ -351,7 +351,7 @@ sub latex_header { $chaptercount = 0; @titlecount = (0); - open ( CHORDPRO, "$dirname/$outfilename.tmp" ) || die "cannot open input file"; + open ( CHORDPRO, '<', "$dirname/$outfilename.tmp" ) || die "cannot open input file"; # read the whole document for settings while ( ){ @@ -421,10 +421,8 @@ sub latex_header { chop $geometry; #delete last comma close ( CHORDPRO ); - - #open temporary file - open ( CHORDPRO, "$dirname/$outfilename.tmp" ) || die "cannot open input file"; + open ( CHORDPRO, '<', "$dirname/$outfilename.tmp" ) || die "cannot open input file"; #print preamble into LaTeX file if ( $output eq "pdf" ) { print TEX "\\pdfoutput=1 @@ -610,14 +608,18 @@ sub latex_footer { #------------------------------------------------------------------------------- sub includes{ - open ( TMP, ">$dirname/$outfilename.tmp" ) || die "cannot open temporary output file"; + open ( TMP, '>', "$dirname/$outfilename.tmp" ) || die "cannot open temporary output file"; + # open input file - open ( CHORDPRO, "$filename" ) || die "cannot open input file"; + open ( CHORDPRO, '<', "$filename" ) || die "cannot open input file"; + while ( ){ if ( /{include:/ ) { #read only lines with an include directive s/({.*:)(.+)(})/\2/; print TMP "#$_\n#\n"; - open ( INSERT, "$dirname/$_" ) || die "cannot open file to insert: $_"; + + open ( INSERT, '<', "$dirname/$_" ) || die "cannot open include file: $_"; + while ( ){ #insert file to include print TMP; } -- 2.20.1