Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Short version of database push for multiple variables

by Eliya (Vicar)
on May 13, 2012 at 16:04 UTC ( #970297=note: print w/ replies, xml ) Need Help??


in reply to Short version of database push for multiple variables

Maybe something like this (if I understand your "append them to corresponding list" correctly):

#!/usr/bin/perl -w use strict; my (@a, @b, @c, @d, @e, @f, @g); while (my $Line = <DATA>) { my @v = split(/\t/, $Line); for my $ar ( \(@a, @b, @c, @d, @e, @f, @g) ) { my $v = shift @v; $v = "NA" unless $v =~ /([A-Za-z0-9-_]+)/; push @$ar, $v; } } use Data::Dumper; print Dumper \(@a, @b, @c, @d, @e, @f, @g); __DATA__ a b c d . f g A B C . E F G

Output:

$VAR1 = [ 'a', 'A' ]; $VAR2 = [ 'b', 'B' ]; $VAR3 = [ 'c', 'C' ]; $VAR4 = [ 'd', 'NA' ]; $VAR5 = [ 'NA', 'E' ]; $VAR6 = [ 'f', 'F' ]; $VAR7 = [ 'g ', 'G ' ];


Comment on Re: Short version of database push for multiple variables
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2014-08-31 03:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (294 votes), past polls