in reply to Useless use of substr in void context
Why use substr($links, 0, 1),if all your going to do is throw away the value and not use it anywhere in your code.
my $sub_extract=substr($links, 0, 1);
and then use $sub_extract for whatever you want.
rgds