#!/usr/bin/perl use warnings; use strict; my @lines = ("C", "B", "A", "E", "D"); while (my $line = shift @lines) { last if $line eq 'A'; } print "@lines";