Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^5: How to add column into array from delimited tab file

by Kenosis (Priest)
on Feb 18, 2014 at 17:27 UTC ( #1075360=note: print w/replies, xml ) Need Help??


in reply to Re^4: How to add column into array from delimited tab file
in thread How to add column into array from delimited tab file

I want to be able manipulate the columns individually (thus attempting array) so I am not sure how hash can help in this case.

In the case of using a hash of arrays (HoA), you can think of the arrays as named--although Perl has no such construct.

For example, running the modified script that only prints the headers and values, the following, single file was used:

ID dataS01R1 dataS01R2 dataS02R1 1 324 445 654 2 234 654 768.5 3 542.12 764 98.2

And here the script's output:

dataS02R1 654 768.5 98.2 dataS01R2 445 654 764 dataS01R1 324 234 542.12

This shows the headers (the keys) followed by the list elements.

The regex /^dataS\d\dR\d$/ matches only the column headings listed above, which have the pattern dataSnnRn, where "n" signifies a digit 0-9.

Thus, the notation @{ $hash{$key} } represents the array of elements under the heading contained in $key.

If you want to process a specific column, use eq instead of a regex, e.g., if ( $key eq 'dataS01R1' ) { ....

This may now lead back to the original, unmodified script which generates a set of files for each processed table, as you can modify the script to fit your needs.

I try running it but there's error which the script keep running without stopping.

The script executes locally as expected, given the datasets you've shared. Without knowing more about your data, it's difficult to troubleshoot the problem you're experiencing.

Hope this helps!

Replies are listed 'Best First'.
Re^6: How to add column into array from delimited tab file
by hellohello1 (Sexton) on Feb 20, 2014 at 01:08 UTC
    Ok Thanks :) Will figure it out somehow.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2021-03-02 09:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favorite kind of desktop background is:











    Results (42 votes). Check out past polls.

    Notices?