@text = ( $text =~ /([a-zA-Z0-9]+\s+[z]{15}\s+[a-z0-9]+)/g) if(@text){ print "first: " . shift(@text) . "\n" if (@text); print "second: " . shift(@text) . "\n" if (@text); } else{ print "Search failed\n"; }