#!/usr/bin/perl -w


my $packge = "";

while( $package = shift )
{
	showDependencies( $package );
}



sub showDependencies
{
    my $package = shift;

    my $available = "/var/lib/dpkg/available";

    my $found    = 0;
    my $required = $package;

    open( AVAIL, "<" . $available );
    while( my $line = <AVAIL> )
    {
        if ( $line =~ /^Package: (.*)/ )
	{
	    my $pkg = $1;
	    if ( $pkg eq $package )
	    {
	        $found =1;
	    }
	}
	
	if ( $line =~ /Depends: (.*)/ )
	{
	    if ( $found  )
	    {
		$required = $1;
	    }
	}
	if ( length( $line  ) < 2)
	{
	    $found = 0;
	}
    
    } 
    close( AVAIL );

    if ( length( $required ) )
    {
        foreach my $bin ( split( /,/, $required ) )
	{
	    $bin =~ s/^\s+//;
	    $bin =~ s/\s+$//;

	    if ( $bin =~ /([^ \t]+)[ \t]+(.*)/ )
	    {
	        $bin = $1;
	    }
	    print $bin . "\n";
	}
    }
}
