it's a minor nitpick, but why use a variable named sub in perl, knowing it's a keyword? if you forget a single sigil you could easily end up with code that runs but does something very unexpected. Also you continue to put "my" in front of graph in two places. In your first for loop, you probably wanted to just put
and leave the second my off. Though because you just initialized your array, you're not going to ever enter that loop until you put something in the @graph array.