I think Niek has covered all the parts of your question but I will answer remaining. @Niek : @t is an array which contains the columns of blat output (psl file). So $t[0] is the first column from psl file which is - number of matches and $t[1] is second column which is number of mismatches.
@Tmy : If you are interested in query sequences, you can modify the script little bit. I think 10th column of blat ouput contains query name. So the script link which Niek has given, you can change line number 34 of code from -
@s[6..10] = ('*', 0, 0, '*', '*');
to
$s[9]=$t[9];
@s[6..8] = ('*', 0, 0);
$s[10]=('*');
Now in final sam output you have query names also, which you can replace with the help of your input fasta file.
P.S: I did not ran the code in my PC but I think it should work.
EDIT : Just realise, you can also use 1st column of sam format (which is query name) and then with the help these names, you can put sequences in 10th column of sam from your input fasta file. So no need of modifying the above script.