#!/usr/bin/perl if (scalar(@ARGV) < 1) { die("Usage: make_config.pl SENSOR_NAME"); } my $name = shift @ARGV; Process("thermo_sensor_v2.things", $name.".things"); Process("thermo_sensor_v2.items", $name.".items"); sub Process { my $src = shift; my $dst = shift; my $fh; open($fh, "< ".$src); my $ofh; open($ofh, "> ".$dst); while (<$fh>) { $_ =~ s/SENSOR_NAME/$name/g; print($ofh $_); } close($fh); close($ofh); }