#!/usr/bin/perl use strict; use warnings; my @history; my $text; my $x; print STDERR "Enter text ('q' to quit): "; $text = ; chomp $text; push (@history, "$text\n"); while ($text ne 'q') { print STDERR "Enter text ('q' to quit): "; $text = ; chomp $text; push (@history, "$text\n"); } my $numberOfHistoryItems = @history; print STDERR "For history, press 'h', else quit:"; my $history = ; chomp $history; if ($history eq "h") { for($x = 0; $x < $numberOfHistoryItems; $x += 1) { print STDOUT "$history[$x]" if $numberOfHistoryItems >0; } print STDOUT "No history items\n" if $numberOfHistoryItems == 0; }