in reply to Re^2: Seeking an Enlightened Path (Parsing, Translating, Translocating)
in thread Seeking an Enlightened Path (Parsing, Translating, Translocating)

In other words, would it be possible to define a string and feed that into unpack, then define another string and feed it into the second part of join?

You'd have to explain that a little better, but someting like this might be close depending where/how you want to obtain those strings, The following would take comma separated arguments to construct the unpack template and field ordering:

perl -e"BEGIN{$T=join'',map{qq[A$_ ]}split',',shift;@F=split',',shift}" -ple"$_ = join'',(unpack $T,$_)[@F]" "10,4,6,6" "2,1,0,3" infile >outfile

But note I've had to split the "one-liner" over several lines for posting. Once they start getting this long, writing a proper script is more convenient if you are going to reuse it.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."
  • Comment on Re^3: Seeking an Enlightened Path (Parsing, Translating, Translocating)
  • Download Code