#!/usr/bin/perl use strict; use warnings; use Text::CSV; use Time::HiRes; my $linenum = 0; my $t0 = Time::HiRes::gettimeofday(); my $elapsed; open(STATES, "<", "states") or die $!; defined($ARGV[0]) or die "Please supply a graph_tree id as first argument"; my $graph_tree_id = $ARGV[0]; print "INSERT INTO `graph_tree_items` (`id`, `graph_tree_id`, `local_graph_id`, `rra_id`, `title`, `host_id`, `order_key`, `host_grouping_type`, `sort_children_type`) VALUES \n"; while() { $linenum++; my $abbr = $_; chomp $abbr; printf "(NULL, %d, 0, 0, '%s', 0, '%03d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000', 1, 1),\n",$graph_tree_id,$abbr, $linenum; } $elapsed = Time::HiRes::gettimeofday() - $t0; printf(STDERR "Parsed %d lines in %.03f seconds\n",$linenum,$elapsed);