http://www.perlmonks.org?node_id=671789


in reply to Question on File position, pulling words

Consider your variables are separated by space, then you can try like,

use strict; while(<DATA>){ chomp; print "IN:$&\n" if($_ =~/\s[^\s]+\s[^\s]+$/); }

Punitha

Replies are listed 'Best First'.
Re^2: Question on File position, pulling words
by taints169 (Initiate) on Mar 04, 2008 at 15:29 UTC
    Perfect thanks everyone! If I wanted to break up the line into 2 seperate variables, would I just search on the space then replace with a new line? I'd like to be able to assign a variable to each one and call each one.
    host_crm-unitc-01_01 server_one_ear-unitc to get: host_crm-unitc-01_01 server_one_ear-unitc