Thanks for replay,
yes i try to use the code mentioned in the example, because the javascript procedure are volatile (as disconnect they disappear and you need to insert again) i save them.
problem is when you try to add a document as example say ({"_id"=> getNextSequence("comm-id")
+,"year" => "2017"}) it work fine, getNexSequence javascript work fine.
but if i call it from perl it is not recognized and executed, so id will be 'getNextSequence("comm-id")' string