Perl stacks, queues, and word frequencies
A Perl array is also a stack and a queue. push adds at the end and pop removes from the end, which gives a last-in, first-out stack. shift removes from the front and unshift adds at the front, so push with shift is a first-in, first-out queue. All four operations are efficient, and no extra module is needed.
Perl
use strict;
use warnings;
my @stack;
push @stack, 1, 2, 3;
my $top = pop @stack;
print "$top @stack\n";
my @queue = (1, 2, 3);
my $front = shift @queue;
push @queue, 4;
print "$front @queue\n";
unshift @queue, 0;
print "@queue\n";
my $text = "the cat and the hat and the bat";
my %freq;
$freq{$_}++ for split ' ', $text;
print join(" ", map { "$_=$freq{$_}" } sort { $freq{$b} <=> $freq{$a} or $a cmp $b } keys %freq), "\n";
my @even = grep { $_ % 2 == 0 } 1 .. 10;
my @squares = map { $_ ** 2 } @even;
print "@even | @squares\n";
my %seen;
my @unique = grep { !$seen{$_}++ } qw(a b a c b);
print "@unique\n";