in reply to gathering of some elements of a list

Looks like fixed width columns, so use that fact...

while( <DATA> ) { my $ieu = substr( $_, 34, 7); $ieu =~ s/\s+//g; substr( $_, 34, 7) = sprintf("%-7s", $ieu || '-'); print; } __DATA__ 0601 3 NORM 2 ALLO XLF753 U 0045 0050 0603 5 NORM 2 ALLO ADR2CG 0430 0438 0604 6 NORM 2 ALLO AF681VC i U 0500 0510 0605 7 NORM 2 ALLO AF651PQ i 0515 0523 0606 8 NORM 2 ALLO AF713BR i 0445 0453 0607 9 NORM 2 ALLO AFR100M i 0520 0533 0609 11 NORM 2 ALLO GJT775 i E 2300 2315 0610 12 NORM 2 ALLO AF661WN i 0450 0500 0500

Output:

0601 3 NORM 2 ALLO XLF753 U 0045 0050 0603 5 NORM 2 ALLO ADR2CG - 0430 0438 0604 6 NORM 2 ALLO AF681VC iU 0500 0510 0605 7 NORM 2 ALLO AF651PQ i 0515 0523 0606 8 NORM 2 ALLO AF713BR i 0445 0453 0607 9 NORM 2 ALLO AFR100M i 0520 0533 0609 11 NORM 2 ALLO GJT775 iE 2300 2315 0610 12 NORM 2 ALLO AF661WN i 0450 0500 0500

I've added $ieu || '-' so that an empty column is replaced with a dash. You may not want that, but I find dealing with delimetered columns easier than fixed width.

update: added output

Replies are listed 'Best First'.
Re^2: gathering of some elements of a list
by steph_bow (Pilgrim) on Jul 30, 2007 at 14:55 UTC

    Thanks a lot FunkyMonk

    That's exactely how I would like the output to be (I can then put a delimitator but the main difficulty was to gather the i, E, U, etc ...)