Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: string value assignment

by ciderpunx (Vicar)
on May 14, 2011 at 11:14 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://904812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-26 01:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found