in reply to Re^3: Combined lines from a file into one
in thread Combined lines from a file into one

#!/usr/bin/perl # http://perlmonks.org/?node_id=1137428 use strict; use warnings; open (my $rangeFixed, '<', "rangeFile.txt") or die "Cannot Open File: +rangeFile.txt $!"; $_ = join '', <$rangeFixed>; s/^(IMB,\d+,V1\s,)(\d+),\K (?:.*\n)+ \1\d+,(\d+).*/$3/gmx; open (my $rangeOutput, '>', "test.txt") or die "Cannot Open File: test +.txt: $!"; print $rangeOutput $_; close $rangeOutput;
It didn't work. The output was all the lines, it didn't combine them?

Replies are listed 'Best First'.
Re^5: Combined lines from a file into one
by poj (Abbot) on Aug 05, 2015 at 15:55 UTC

    Can you put your data in code tags, it looks like you have more than 1 space here
    V1      ,
    If so regex should have + here V1\s+,
    poj