It looks like you can use quest::MerchantSetItem to add merchant inventory through a perl script. I have never used this but maybe? Replace npcid with the npc's ID, and howmanycaps with the total number you would like the npc to stock.
Code:
sub EVENT_SAY {
if ($text=~/hail/i)
{
quest::say("a response.");
}
}
sub EVENT_SPAWN {
#quest::MerchantSetItem(uint32 npc_id, uint32 item_id, [uint32 quantity])
quest::MerchantSetItem(npcid, 1001, howmanycaps);
}