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.
|
|---|