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