in reply to splitting the bus and print

++ to AnomalousMonk that is exploring more and more the regex alien world (can we hope in some new tutorial: regex power tools 2016..?)

If I understand the OP's question it this enough a oneliner:

perl -nlE "push @res,/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_; +END{say for @res}" portbus.txt
# some number is different cat portbus.txt [15:0]abc [3:0]def ghi jkl [3:0]mno [6:0]pqr stu etc perl -nlE "push @res,/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_; +END{say for @res}" portbus.txt abc[0] abc[1] abc[2] abc[3] abc[4] abc[5] abc[6] abc[7] abc[8] abc[9] abc[10] abc[11] abc[12] abc[13] abc[14] abc[15] def[0] def[1] def[2] def[3] ghi jkl mno[0] mno[1] mno[2] mno[3] pqr[0] pqr[1] pqr[2] pqr[3] pqr[4] pqr[5] pqr[6] stu etc
Update:
perl -nlE "say for/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_" po +rtbus.txt
L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: splitting the bus and print -- oneliner
by perl vams (Initiate) on Apr 26, 2016 at 11:48 UTC
    the below two options you suggested are not working for me. I'm getting error as "Bad : modifier in $ ($).". Can u please help me on this......
    perl -nlE "say for/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_" po +rtbus.txt perl -nlE "push @res,/\[(\d+):(\d+)\](\w+)/?map{$3.qq([$_])}$2..$1:$_; +END{say for @res}" portbus.txt
      Bad : modifier in $ ($). seems to me not a Perl error.

      A fast search indicate a C-shell or Tcsh as responsable for that error.

      Please note also that, unfortunately, i used the " doublequote to delimit the oneliner, and this because i'm, unfortunately, on windows. Linux users must use signle quote around code '

      L*

      There are no rules, there are no thumbs..
      Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.