All pastes #595772 Raw Edit

kyrh

public text v1 · immutable
#595772 ·published 2007-06-29 17:27 UTC
rendered paste body
#!/usr/local/bin/perl -w

use strict;
use warnings;

my $tmpl = <<EOF

                                <item type="4" key="--DESCR--" value_type="--TYPE--">
                                        <description>--DESCR--</description>
                                        <delay>60</delay>
                                        <history>7</history>
                                        <trends>365</trends>
                                        <status>1</status>
                                        <snmp_community>public</snmp_community>
                                        <snmp_oid>--OID--</snmp_oid>
                                        <snmp_port>161</snmp_port>
                                </item>
EOF

while(<>)       {
        die "Bad strings '$_'\n"
                unless /^.*([^.]\.\d)\t([\d.]+)\t([^\t]+)\t?([\d]*);

        my %hash = ('descr' => $1, 'oid' => $2, 'type' => $4);

        $s =~ s/--DESCR--/$hash{$1}/g;
        $s =~ s/--OID--/$hash{$2}/g;
        $s =~ s/--TYPE--/$hash{$3}/g;

        print $s, "\n";
}