#!/bin/perl5 use strict; use warnings; my @array = ( 'abcedf 5163 1234 5678', '1234516323943293' ); for ( @array ){ /(5163.*)/; print "$1\n"; }