in reply to Re: why aren't I see the hash while using dump?
in thread why aren't I see the hash while using dump?

now, moving on to do more interesting stuff with hashes...I am having problems with new $k and $v to already existing read in hash . can you help debug this piece? where I attempt to check in data2 with already existing hash{key}=$value?? I added this piece to the code which previously loaded the hash from 1st file.
<data> uno = uno due = dos tre = tres quattro = quatro cinque = cinco <\data> <data2> uno => tree due => dos tre => tres quattro => cinco cinque => cinco sei => seis <\data2>
use strict; use warnings; use Data::Dump qw(dump); use Storable; #don't know what this does yet. my %hash; open my $in, '<',"./test_data.txt" or die ("can't open the file:$!\n") +; while (<$in>){ chomp; my ($key, $value)= split (/\s*=\s/); $hash{$key}=$value; } close $in; ## <new code> open my $in2,'<',"./test_data2.txt" or die ("can't open file : $!\n"); open my $out ,'>' ,"./test_data_out.txt" or die "can't open the file f +or write:$1\n"; while (<$in2>){ chomp; my ($key,$value) = split (/\s*=\s/); #splits row into 2 col #will check if new key,value matches then print to another file for f +un. if exists $hash{$keys}{ dump \$out; } }

Replies are listed 'Best First'.
Re^3: why aren't I see the hash while using dump?
by Anonymous Monk on Jun 02, 2015 at 01:29 UTC

    ... <data>...<\data> ... <data2>...<\data2> ... <code>...<\code> ...

    Maybe you didn't notice it but
    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!

      I apologize for not getting the format correct. I'm working/learning how to communicate here. also, how to update a follow up question? I tried but I am Unable. thanks!

Re^3: why aren't I see the hash while using dump?
by perlynewby (Scribe) on Jun 02, 2015 at 07:51 UTC

    hopefully, I formatted this correctly. stuck while reading in the second keys and values of 2nd file and checking against the existing hash key and value can you help debug this piece?

    uno = uno due = dos tre = tres quattro = quatro cinque = cinco
    uno = tree due = dos tre = tres quattro = cinco cinque = cinco sei = seis
    use strict; use warnings; use Data::Dump qw(dump); use Storable; #don't know how to use this to test yet. my %hash; open my $in, '<',"./test_data.txt" or die "can't open the fi +le:$!\n"; while (<$in>){ chomp; my ($key, $value)= split (/\s*=\s/); $hash{$key}=$value; #it's clear to me now } close $in; #will check against %hash with new keys and values #opening files for read and write open my $in2,'<',"./test_data2.txt" or die "can't open file : $!\n"; open my $out ,'>' ,"./test_data_out.txt" or die "can't open the file f +or write:$!\n"; while (<$in2>){ chomp; my ($key,$value) = split (/\s*=\s/); #splits row into 2 col if exists $hash{$keys}{ dump $out \%hash; } }


      my ($key,$value) = split (/\s*=\s/);
      if exists $hash{$keys}{
         dump $out \%hash;
      }


      Are you using use strict; use warnings; ? That would immediately tell you you are using a variable that has not been declared previously.
      Please use that from now on...

        I am using the strict but didn't understand exactly what it wanted. I know now.

        I am using netbeans, would you recommend for me to stay on netbeans or use eclipse? I read somewhere that eclipse has a nice debugger walker and I haven't seen one for netbeans.

        by the way, I apologize for wrongful formats and basic questions but this will be improving...I find Perl to be a cool tool and ,also, still figuring out all these tools at PerlMonks on how to communicate effectively. thanks