#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use diagnostics; undef $/; my $text = ; while ($text =~ /alpha\|([^|]+)\|/smg) { print "match: $1\n"; } __DATA__ alpha|beta|alpha|theta|alpha|gamma|alpha|episilon