Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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!


In reply to Re^5: How to add column into array from delimited tab file by Kenosis
in thread How to add column into array from delimited tab file by hellohello1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2021-12-05 09:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?