Queue is a data structure which contains a list of items. Queue works on a mechanism called First-In-First-Out (FIFO) or first come first serve. The first item is added to the queue is the first one to be removed.
Array in Perl can be used as a queue. To add an item to the start of the queue you use the unshift function, to remove an item from the start of the queue you use shift function. The code snippets is as follows: