1) use Data::Dumper to print the contents of $keywords, so that you know how to access the data inside it
2) you are just talking about using 'fetchall_arrayref()' is amateurish, IMO it is not.
3) see
perllol to know about array of arrays and ways to access it.
4) you are worrying about a problem, where it is not a problem at all. Concentrate on something else which is much important to you than this.
UPDATE
I'm trying to improve my coding skills
try this
Real Life Perl Exercises
Recommended Reading
Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.