#!/usr/bin/perl use strict; use warnings; while (defined( $_ = )) { my $one = $1 if s/^(\{\w+\s+\d+\}) //; my $two = $1 if s/^(.*)//; print "ONE: $one\n"; print "TWO: $two\n"; } __DATA__ {STRING 4} 123.122.124.125 some text here