@commands = ("add_node('W1')", "add_node('W2')", "add_edge('W2' => 'W1')"); #### use GraphViz; my $g = GraphViz->new(); foreach $command (@commands) { $g->$command; }