in reply to text processing - convert list of vectors to tabular format
Hi vnpenguin,
Use each_array method in List::MoreUtils module.
use strict; use List::MoreUtils qw(each_array); undef $/; my $text=<DATA>; my $a=$1 if $text=~m#v_x \{([^\}]+)\}#; my @a=split( "\n", $a ); my $b=$1 if $text=~m#v_y \{([^\}]+)\}#; my @b=split( "\n", $b ); my $c=$1 if $text=~m#v_z \{([^\}]+)\}#; my @c=split( "\n", $c ); my $ea = each_array(@a, @b, @c); while ( my ($a, $b, $c) = $ea->() ) { print "$a\t$b\t$c\n"; } __DATA__ v_x { x1 x2 x3 x4 x5 x6 x7 x8 } v_y { y1 y2 y3 y4 y5 } v_z { z1 z2 z3 z4 z5 z6 }
OUTPUT:
x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 x5 y5 z5 x6 z6 x7 x8
Thanks,
Gopal.R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: text processing - convert list of vectors to tabular format
by vnpenguin (Beadle) on Dec 15, 2005 at 10:42 UTC |