File: varrep.pl

package info (click to toggle)
dawg 1.2-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 908 kB
  • sloc: cpp: 2,598; ansic: 520; perl: 467; sh: 101; makefile: 18
file content (24 lines) | stat: -rw-r--r-- 496 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#! /usr/bin/perl -w -ibak
# Copyright (2005) Reed A. Cartwright.  All rights reserved.
#
# varrep.pl is used to substitute varables in files
#
# usage: perl varrep.pl file
#
# right now the only variable supported is #NUM#
# useful for modifying the code blocks of Nexus files produced by Dawg
#
# Distributed under the same license as DAWG
#


use strict;

my %vars = (NUM => 0);

while(<>)
{
	$vars{NUM} = $1 if(/\[DataSet (\d+)\]/);
	s/#(\w+)#/$vars{$1}/ge;
	print $_;
}