in reply to one liner to capture value of field and insert in another field

pipe (|) is special in regular expressions. And you shouldn't use \1 in right hand side of s///. In fact, you shouldn't use s/// at all. split is what you need.
$ perl -F'\|' -lane '$F[10] = $F[7]; print join "|", @F' file.txt row|1|CUSIP|12345678|RED|||20150125|||20150125| row|1|CUSIP|1234A82H|RED|||20150316|||20150316|
(see perlrun for details)

Replies are listed 'Best First'.
Re^2: one liner to capture value of field and insert in another field
by dirtdog (Monk) on Jan 28, 2015 at 15:41 UTC

    Works like a charm. Thanks you!

Re^2: one liner to capture value of field and insert in another field
by Anonymous Monk on Jan 28, 2015 at 15:37 UTC
    (choroba, great minds think alike! :)
Re^2: one liner to capture value of field and insert in another field
by dirtdog (Monk) on Jan 28, 2015 at 16:04 UTC

    I guess i jumped the gun a little bit. My apologies. It works for the sample i provided, but the real file has almost 300 fields in each record..some of those values are populated and some aren't...so simply joining a "|" at the end doesn't work for the actual file.

    is there a way to do what you did but instead of Joining one pipe at the end can we somehow join the remaining ~300 col values to each record?

    row|1|CUSIP|35472T200|ARDIV|||20150112|||||||||||||||||||||||||||||||| +|||||||||||||||||||||20150321||||||G||||||||||||||||||||FR||||||||||| +||||||||||||||||||||||||||||||||||||X|||||||||||||||||||||||||||||||| +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||||||||||||||||||||||||||||||||LIQ|||||||||||||||||||||||||| +||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| +||||||||||||

    Sorry for the incomplete data and thx again.

      The problem with split is that by default, trailing empty fields are discarded. You can specify a negative count to prevent that, but you need to be more explicit in such a case:
      perl -lne '@F = split /\|/, $_, -1; $F[10] = $F[7] ; print join "|", +@F'
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        I was just about to say that! :) It took me a while to figure out what dirtdog is saying about his file.
      You mean the records are spread out across several lines? And what separates them?

        it's a pipe delimited file with around 300 columns. So i just need to take the date that would be in column 8 and insert it into column 11, but all other values stay the same.