Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: Hash Question

by choroba (Chancellor)
on Jan 09, 2013 at 11:19 UTC ( #1012435=note: print w/replies, xml ) Need Help??


in reply to Re^2: Hash Question
in thread Hash Question

You probably mean
for my $value (@text[11, 12, 14, 15, 19]) { if ($bHash{ $text[3] } eq $value) { $bHash{ $text[0] } = $value; last; } }
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^4: Hash Question
by perlnoobster (Sexton) on Jan 09, 2013 at 11:37 UTC
    Hi Choroba, That's exaclty what I mean! but i can't figure out what's wrong with it? i've included it in my coding but it doesn't work:
    foreach (<$ah>) { my $nullval = ' '; my @text = split(/\t/); my $value (@text[11, 12, 14, 15, 19]) if ($bHash{ $text[3] } eq $value) { $bHash{ $text[0] } = $value; last; print OUT2 join( "\t", @text[1,2,3,4,11,5,6,8,7,11,12]),"\t$nullva +l\t$nullval\t$nullval\t$nullval\t$nullval\t$nullval\t$nullval\t$nullv +al\t$nullval\t$nullval\t1\t1\n"; } }
      The for is also important.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Ok that's cool, but I've placed it under the foreach and it's still showing errors:
        foreach (<$ah>) for my $value (@text[11, 12, 14, 15, 19]) { my $nullval = ' '; my @text = split(/\t/); if ($bHash{ $text[3] } eq $value) { $bHash{ $text[0] } = $value; last; print OUT2 join( "\t", @text[1,2,3,4,11,5,6,8,7,11,12]),"\t$nullva +l\t$nullval\t$nullval\t$nullval\t$nullval\t$nullval\t$nullval\t$nullv +al\t$nullval\t$nullval\t1\t1\n"; }

      You're making stuff up again, for loop is for loop, its a for loop

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012435]
help
Chatterbox?
[james28909]: it would be to much work just to get around renaming three subs lol
[james28909]: but you could put it all in one sub and return the same data type that was inputted. i could write a small example maybe
[Lady_Aleena]: Their uses are also vastly different.
[Lady_Aleena]: The first two make hashes and arrays from a file, the third returns data from a pre-existing hash.
[Lady_Aleena]: Well, HoH and AoH respectively.

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2017-05-24 05:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?