http://qs321.pair.com?node_id=630328

mifflin has asked for the wisdom of the Perl Monks concerning the following question:

I have some data files that were created without newlines that need to be fixed.
The files contain a bunch of records with an xml file name at the end.
They look like...

somedata file.xmlsomedata file.xmlsomedatafile.xml ....

what I want them to be is ...

somedata file.xml
somedata file.xml
somedata file.xml
...

So , i thought I could use a piecewize regex like so...
pos $data = 0; my $len = length $data; while (pos $data < $len) { if ( my ($line) = $data =~ m{ \G ( .+ \. xml ) }gcxms ) { print "$line\n"; } }
The problem is I cannot figure out how to make the regex non-greedy. My capturing portion matches the full string, all the way to the last xml file. How to I change the regex to be non-greedy and match up to the first xml file?