# tie your array to the file tie @chat, 'DB_File', 'chat', O_CREAT | O_RDWR, 0644, $DB_RECNO; # push the message info onto the array push @chat, "Message number $_" for (1 ..20); # print the last five messages print join "\n", @chat[-5 .. -1]; __END__ output: Message number 16 Message number 17 Message number 18 Message number 19 Message number 20