Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/env perl use strict; use warnings; my $file1 = "2hgs_d00_internal_nrg_e.dat"; my $file2 = "2HGS_bio_conv-min_p.pdb"; open( MYFILE, '<', $file1 ) or die "cannot open $file1: $!"; open( NEWF, '<', $file2 ) or die "cannot open $file2: $!"; my (@a_vals, @b_vals); while ( <MYFILE> ) { chomp; my( $label, $index, $value ) = ( split /\s+/ )[3, 5, -1]; $a_vals[ $index ] = $value; $b_vals[ $index ] = $value; } close MYFILE; while ( <NEWF> ) { chomp; my @fields = ( split /\s+/ ); my $index = $fields[4]; my $label = $fields[-1]; if ($label eq "A"){ $fields[-2] = $a_vals[ $index ] } if ($label eq "B"){ $fields[-2] = $b_vals[ $index ] } my $output = join "\t", @fields; print "$output\n"; } close NEWF;
I am still getting values from B from MYFILE

In reply to Re^10: incrementing already existing file by wanttoprogram
in thread incrementing already existing file by wanttoprogram

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [oakbox]: but there are a billion links 'out there' linking to search.cpan.org.
    [marto]: yep :)
    [Discipulus]: being her marto, can you explain what "Par for the course I'm afraid." means?
    Discipulus here..
    [marto]: "what is normal or expected in any given circumstances."
    [marto]: better: "If a type of behaviour, event, or situation is par for the course, it is not good but it is normal or as you would expect"
    [Discipulus]: thanks i was unable to decide where to split the sentece
    [marto]: FWIW search.cpan rarely has issues, see http://noc.perl. org for a route to report problems
    [oakbox]: thanks, marto.
    [marto]: there was a period where search.cpan had some frequent outages for (IIRC) a couple of weeks. I've not had any problems since, until today.

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2017-07-26 10:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      I came, I saw, I ...
























      Results (388 votes). Check out past polls.