perl script to convert adjacency list to a matrix