I don't use MongoDB much and you didn't provide a working script to start with so I can't really provide an answer. I can however point you to a snippet of code that I found that might help. I did a Google search for "perl mongodb slice" without the quotes and the fifth result was Example of using $slice and fields() in the MongoDB Perl driver 0.45.
In reply to Re: Need help with $slice MongoDB
by Mr. Muskrat
in thread Need help with $slice MongoDB
by vinaybond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |