Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by gopalr (Priest)
on Dec 15, 2005 at 09:29 UTC ( [id://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

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
    Hi Gopal.R, Thank you so much for your reply. Regards,

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-19 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found