Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: string value assignment

by ciderpunx (Vicar)
on May 14, 2011 at 11:14 UTC ( #904812=note: print w/replies, xml ) Need Help??


in reply to string value assignment

Its normally helpful if you post your code and describe what you are having difficulty with. But I'm at a loose end so try:
#!/usr/bin/perl use warnings; use strict; open (IN, 'first.txt') or die ("crap! $!"); my @first = <IN>; close IN; open (IN, 'second.txt') or die ("crap! $!"); my @second = <IN>; close IN; my %h; my $i=0; for (@second) { ($h{'A'},$h{'B'},$h{'C'}) = split / /,$_; my @keys = split //,$first[$i]; my $total = 0; for(@keys) { $total+= int($h{$_}) unless /\n/; } $total/=scalar(@keys) if($total); print "$i: $total \n"; $i++; }


Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2020-10-01 17:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (17 votes). Check out past polls.

    Notices?