#!/usr/bin/perl
#!/usr/local/bin/perl
use DBI;

# ($article,$letter) = split("/", $ARGV[0]);
# we don't need this complicated nonsense anymore

# Connection do DB
$dbh = DBI->connect("DBI:Pg:dbname=en;host=localhost","","");

$path = $dbh->quote( $ARGV[0] );

# Query
$q = $dbh->prepare( "
        SELECT caption.head AS head, caption.text AS text, index.name AS name
        FROM caption, institute, index
        WHERE caption.id = $path
		AND institute.id = caption.institut
		AND institute.id = index.id
");
$q->execute;

# Dump results
@res = $q->fetchrow_array;
print $res[0]."\n";     # Head
print $res[1]."\n";		# Text
print $res[2]."\n";    	# Name

