in reply to Read file in a hash and compare the 'values' from file 2
So now I have got keys and values.
You may think you do, but you don't. Post runnable code ala How do I post a question effectively?, like
#!/usr/bin/perl -- #~ 2011-07-05-05:39:58 Anonymous Monk #~ http://perlmonks.com/?node_id=912812# Read file in a hash and compa +re the 'values' from file 2 #~ perltidy -csc -otr -opr -ce -nibc -i=4 use strict; use warnings; use autodie; use Data::Dumper qw/ Dumper /; use 5.010; Main(@ARGV); exit(0); sub Main { if ( @_ == 2 ) { NotDemoMeaningfulName(@_); } else { Boobbly(); print Usage(); } } ## end sub Main sub NotDemoMeaningfulName { my ( $inputFile, $outputFile ) = @_; open my ($inFh), '<', $inputFile; open my ($outFh), '>', $outputFile; my $d; my $read; my %hash; while (<$inFh>) { $d = $_; $read .= $d; my ( $key, $val ) = split /\n/, $read; $hash{$key} = $val; } ## end while (<$inFh>) print $outFh Dumper( \%hash ); } ## end sub NotDemoMeaningfulName sub Usage { <<"__USAGE__"; $0 inputfile outputfile __USAGE__ } ## end sub Usage sub Boobbly { #~ http://perlmonks.com/?abspart=1;displaytype=displaycode;node_id=912 +812;part=1 my $Furrry = <<'__Furrry__'; >1 ##key abcdef ##value >2 hijkl >3 abnikhl..etc __Furrry__ NotDemoMeaningfulName( \$Furrry, \my $Farts ); print $Farts, "\n\n"; } ## end sub Boobbly __END__ $VAR1 = { '>1 ##key' => 'abcdef ##value' };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Read file in a hash and compare the 'values' from file 2
by Anonymous Monk on Jul 05, 2011 at 13:14 UTC | |
by Anonymous Monk on Jul 05, 2011 at 13:44 UTC |