Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: text processing - convert list of vectors to tabular format

by gopalr (Priest)
on Dec 15, 2005 at 09:29 UTC ( #516892=note: print w/ replies, xml ) Need Help??


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


Comment on Re: text processing - convert list of vectors to tabular format
Select or Download Code
Re^2: text processing - convert list of vectors to tabular format
by vnpenguin (Beadle) on Dec 15, 2005 at 10:42 UTC
    Hi Gopal.R, Thank you so much for your reply. Regards,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://516892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-12-27 02:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls