Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#!/usr/bin/env perl
use DirHandle;
use File::Copy;
$oldfile = @ARGV[0];
$destination = @ARGV[1];
open( INFILE, "$oldfile") || die "ERROR::could not open input file $oldfile";
while( $record = <INFILE> )
{
    if($record =~ /LD_LIBRARY_PATH=/){
	print "$record\n";
	@tok1 = split(/=\"/, $record);
	print "@tok1\n";
	#pop(@tok1);
	#pop(@tok1);
	print "this is tok1\n";
	print "@tok1[1]\n";
	mkdir ($destination);
	opendir(LIBS,$destination);
	@tokens = split(/\:/,@tok1[1]);
	while($#tokens != -1)
	{
	    if(@tokens[$#tokens] =~ /\$/)
	    {}
	    else
	    {
		print "token $#tokens @tokens[$#tokens]\n";
		opendir( DIR, @tokens[$#tokens]);
		@dots = grep {(/\.so/ || /\.a/ || /\.0/)} readdir(DIR);
		while($#dots != -1)
		{
		    $foundlink = readlink "$destination\/@dots[$#dots]";
#		    print "$foundlink\n";
		    system `rm $destination\/@dots[$#dots]` if $foundlink;
#		    symlink("@tokens[$#tokens]\/@dots[$#dots]","$destination\/@dots[$#dots]");
		    copy("@tokens[$#tokens]\/@dots[$#dots]","$destination\/@dots[$#dots]");
		    pop(@dots);
		}
		print "@dots\n";
	    }
	    pop(@tokens);
	}
    }
}