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

It works now it was missing the space. Thanks for this catch. Now, I want to try to plug in variables. Can I use a variable for this:
s/^(IMB,\d+,V1\s+,)(\d+),\K (?:.*\n)+ \1\d+,(\d+).*/$3/gmx; s/^($type,\d+,$version,)(\d+),\K (?:.*\n)+ \1\d+,(\d+).*/$3/gmx;
do you think it will work?

Replies are listed 'Best First'.
Re^5: Combined lines from a file into one
by poj (Abbot) on Aug 05, 2015 at 16:40 UTC
    Yes, if you mean like this
    my $type = 'IMB'; my $version = 'V1'; s/^($type,\d+,$version\s+,)(\d+),\K (?:.*\n)+ \1\d+,(\d+).*/$3/gmx;

    or do you mean the file contains records other than IMB,V1 ?
    poj