in reply to simple perl program not working

Can somebody suggest what could be the problem?

Yep. You don't use strictures: use strict; use warnings;

If you did you'd notice that you assign some stuff to @x then chomp @a.

Get into the habit of using sensible variable names even for trivial one off scripts. Single letter variable names are almost never meaningful and in some cases ($a and $b in particular - see sort) conflict with built in variables.

Perl is the programming world's equivalent of English