in reply to SQL solution or Perl solution?
Since you seem to think Perl offers the likeliest solutions to all your problems, you should just learn Perl.