[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qsos-commits] qsos/tools/createemptysheet createemptysheet.pl
From: |
Goneri Le Bouder |
Subject: |
[Qsos-commits] qsos/tools/createemptysheet createemptysheet.pl |
Date: |
Fri, 10 Nov 2006 22:35:44 +0000 |
CVSROOT: /sources/qsos
Module name: qsos
Changes by: Goneri Le Bouder <goneri> 06/11/10 22:35:44
Added files:
tools/createemptysheet: createemptysheet.pl
Log message:
a tool to create empty QSOS sheet from .inc and .qtpl files
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qsos/tools/createemptysheet/createemptysheet.pl?cvsroot=qsos&rev=1.1
Patches:
Index: createemptysheet.pl
===================================================================
RCS file: createemptysheet.pl
diff -N createemptysheet.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ createemptysheet.pl 10 Nov 2006 22:35:44 -0000 1.1
@@ -0,0 +1,43 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use Getopt::Long;
+
+my $includedir;
+my $qtpl;
+
+GetOptions (
+ 'include=s' => \$includedir,
+ 'qtpl=s' => \$qtpl,
+);
+
+sub usage {
+ my $msg = shift;
+ print STDERR $msg."\n" if $msg;
+
+ print STDERR "usage:\n";
+ print STDERR " createemptysheet --include=/includepath --qtpl
qsos-template.qtpl:\n";
+ exit 1;
+}
+
+usage("Missing argument") if ! (defined $includedir && defined $qtpl);
+usage("Can't find include directory") if ! -d $includedir;
+usage("Can't find template file") if ! -f $qtpl;
+
+my @buff;
+open QTPL,"<$qtpl" or die "Failed to open $qtpl: $?";
address@hidden = <QTPL>;
+close QTPL;
+
+while (my $line = shift @buff) {
+ if ($line =~ /<include\W+section="(\w+)"\/>/) { # this is an include
+# print STDERR "Including $1\n";
+ open INCLUDE, "<$includedir/$1.qin" or die "Failed to open includefile
+ $1.qin";
+ unshift @buff, <INCLUDE>;
+ close INCLUDE;
+ } else {
+ print $line;
+ }
+}
- [Qsos-commits] qsos/tools/createemptysheet createemptysheet.pl,
Goneri Le Bouder <=