Re: Perl hash

2015-07-31 Thread bikram behera
Thanks Shlomi. On Fri, Jul 31, 2015 at 3:36 PM, Shlomi Fish wrote: > On Fri, 31 Jul 2015 09:08:06 +0530 > bikram behera wrote: > > > Hi Team, > > > > Please send me hash uses and concept > > > > Please see http://perl-begin.org/topics/hashes/ and especially "The Hash > Cookbook" link. > > Reg

Re: Perl hash

2015-07-31 Thread Shlomi Fish
On Fri, 31 Jul 2015 09:08:06 +0530 bikram behera wrote: > Hi Team, > > Please send me hash uses and concept > Please see http://perl-begin.org/topics/hashes/ and especially "The Hash Cookbook" link. Regards, Shlomi Fish > > Thanks, > Bikram -- -

Re: Perl hash

2015-07-31 Thread Andrew Solomon
One other thing - if you're familiar with other programming languages you may have come across the idea of hash with a different name such as 'associative array', 'dictionary', 'map' or 'symbol table' https://en.wikipedia.org/wiki/Associative_array Andrew On Fri, Jul 31, 2015 at 10:31 AM, Martin

Re: Perl hash

2015-07-31 Thread Martin Barth
and hashes are not sorted, like lists are. Martin Am 31.07.2015 um 08:28 schrieb Uday Vernekar: > Hashes are complex list data, like arrays except they link a key to a > value. > Hashes can be used for counting, uniqueness, searching, and dispatch and > lot more than just mapping from one thing t

Re: Perl hash

2015-07-30 Thread Uday Vernekar
Hashes are complex list data, like arrays except they link a key to a value. Hashes can be used for counting, uniqueness, searching, and dispatch and lot more than just mapping from one thing to another and More. On Fri, Jul 31, 2015 at 9:15 AM, Uri Guttman wrote: > On 07/30/2015 11:38 PM, bikra

Re: Perl hash

2015-07-30 Thread Uri Guttman
On 07/30/2015 11:38 PM, bikram behera wrote: Hi Team, hi, we aren't a team. this is a public mailing list. Please send me hash uses and concept think of them as arrays but instead of integers for indexing, you use strings. the uses are too many to list here. some are data structures, ta

Re: Perl Hash concept.

2015-07-03 Thread Kent Fredric
On 3 July 2015 at 18:54, bikram behera wrote: > Hi Team, > > > Any body can explain me how to do perl hash refernce and dereference. > Create a hash: my (%hash) = ( "key" => "value" , "otherkey" => "othervalue" ); Create a reference to said hash: my $reference = \%hash; You can also make a h

Re: perl hash loop: keys() vs values()

2013-06-15 Thread richard
Thanks. I looked at this site while searching for solutions but I probably skipped the section on sorting because I wasn't sorting the hash. regards, Richard -- tmqrich...@gmail.com On Sun, Jun 16, 2013 at 3:17 AM, Peter Gordon wrote: > On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote: > >Hi >

Re: perl hash loop: keys() vs values()

2013-06-15 Thread Peter Gordon
On Sat, 15 Jun 2013 12:12:56 -0400, richard wrote: >Hi > >I'm trying to understand the difference between the keys() and >values () operators. What I'm not getting is why a hash must be >reversed to get the key corresponding to a value? (as stated in >perldoc). Can someone explain this please? > >

Re: perl hash loop: keys() vs values()

2013-06-15 Thread richard
Octavian Thanks for taking the time to write such a thorough reply. My question is completely answered by this section: You can't get the key for a certain value. Say you have the following hash: my %hash = (a => 1, b => 2, c => 3, d => 2, e => 2); What's the key for the value "2"? I was so pr

Re: perl hash loop: keys() vs values()

2013-06-15 Thread Octavian Rasnita
Perl has 2 types of arrays: common arrays and associative arrays which are called hashes. In order to get the value of an item from an ordinary array, you need to specify the index of that array, for example: my @array = (1, 2, 3); print $array[1]; #will print "2" (because the indexes start fr

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-04 Thread Rob Dixon
On 05/04/2011 01:11, Chris wrote: Actually, I had tried following the thread and it it looked like the code you used from J W Krahn had that information in arrays and not strings. That is actually why I set it up that way. However, if the data is in a string form, the code may be a bit clearer

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-04 Thread charley
On Apr 4, 3:03 am, wekst...@gmail.com (Wernher Eksteen) wrote: > > Hello Wernher, > > Hi Chris, > > > Rob's code could be reconfigured slightly to do so, but requires a > > different approach.  I will paste it below. > > Ok, thanks. > > > One change I made was to make the *values* of %hash1 an arra

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-04 Thread Wernher Eksteen
> Hello Wernher, Hi Chris, > Rob's code could be reconfigured slightly to do so, but requires a > different approach. I will paste it below. Ok, thanks. > One change I made was to make the *values* of %hash1 an array ref as I > thought this was how the hash was originally constructed. If the v

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread charley
On Apr 3, 2:31 pm, crypt...@gmail.com (Wernher Eksteen) wrote: > > I suggest you reduce your tab size from eight characters, which leave > > your code spread out and less readable. Four or two is more usual > > nowadays. > > Thank you, I will do so from now on. > > > Meaningful variable names are a

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Hi Shawn, Thank you very much, Shown from your code below and my print1 and prin2 comments below: print1 correctly prints the following: emcpoweraa sdae sdch sdek sdgn /dwpdb033 emcpowerd sdba sddd sdfg sdhj /odsdb005 emcpowerc sdbb sdde sdfh sdhk /odsdb006 emcpowerbc sdb sdbe sddh sdfk /s00_11

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Hi John, >%hash1 > emcpowera sdbd sddg sdfj sdhm >emcpoweraa sdae sdch sdek sdgn >emcpowerbc sdb sdbe sddh sdfk >emcpowerc sdbb sdde sdfh sdhk >emcpowerd sdba sddd sdfg sdhj > >%hash2 >emcpowera1 /dwpdb006 > emcpoweraa1 /dwpdb033 >emcpowerbc1 /s00_11 >

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread John W. Krahn
Wernher Eksteen wrote: Hi, Hello, How do I compare the column 1 in %hash2, with column 1 in %hash1 so that when a match is found to append or concatenate the hash key (column 1) and it's associated values from %hash2 with that of %hash1 and build a new hash %hash3 as the end result. %hash1 e

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread shawn wilson
yeah, i didn't read the sample output. so, here ya go. On Sun, Apr 3, 2011 at 6:06 PM, Rob Dixon wrote: > On 03/04/2011 18:05, Wernher Eksteen wrote: >> Got this to work, but is there a better way to do this? >> >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> my ( $val, @matched,

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
> I suggest you reduce your tab size from eight characters, which leave > your code spread out and less readable. Four or two is more usual > nowadays. Thank you, I will do so from now on. > Meaningful variable names are also important. Using $i as the key to > %hash1 and $b as the key to %hash2

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Rob Dixon
On 03/04/2011 18:05, Wernher Eksteen wrote: > Got this to work, but is there a better way to do this? > > #!/usr/bin/perl > > use strict; > use warnings; > > my ( $val, @matched, @unmatched, %hash1, %hash2 ); > > %hash1 = ( > "emcpowera" => "sdbd sddg sdfj sdhm", > "emcpoweraa" => "sdae sdch

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
> so, lets do what you asked (i like hashes better anyway :) ) > > my %hash3, %nothash; > my $found = 0; > while( my( $ikey, $ival ) = each( %hash1 ) ) { >   while( my( $jkey, $jval ) = each( %hash2 ) ) { >      if( ( $ikey == $jkey ) and ( $ival == $ikey ) ) { >         $hash3{ $ikey } = $ival; >

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Rob Dixon
On 03/04/2011 18:35, shawn wilson wrote: so, lets do what you asked (i like hashes better anyway:) ) my %hash3, %nothash; my $found = 0; while( my( $ikey, $ival ) = each( %hash1 ) ) { while( my( $jkey, $jval ) = each( %hash2 ) ) { if( ( $ikey == $jkey ) and ( $ival == $ikey ) ) {

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread shawn wilson
On Sun, Apr 3, 2011 at 5:05 PM, Wernher Eksteen wrote: > Got this to work, but is there a better way to do this? > > #!/usr/bin/perl > > use strict; > use warnings; > > my ( $val, @matched, @unmatched, %hash1, %hash2 ); someone else is sure to call you out on defining this stuff at the beginning

Re: Perl Hash Comparison and concatenate result from %hash2 compared to %hash1 into %hash3

2011-04-03 Thread Wernher Eksteen
Got this to work, but is there a better way to do this? #!/usr/bin/perl use strict; use warnings; my ( $val, @matched, @unmatched, %hash1, %hash2 ); %hash1 = ( "emcpowera" => "sdbd sddg sdfj sdhm", "emcpoweraa" => "sdae sdch sdek sdgn", "emcpowerbc" => "sdb sdbe sddh sdfk", "emcpowerc" => "sdbb

Re: Perl Hash of arrays : comparison

2006-03-21 Thread John W. Krahn
Sonika Sachdeva wrote: > Hi, Hello, > I have Hash of array. I want to compare the array values within the hash. > How can it be done? > > if ($eline =~ /$pattern/ ) { > $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my > $url=$4; You shouldn't use the numerical variables i

Re: Perl Hash of arrays : comparison

2006-03-21 Thread Mr. Shawn H. Corey
Sonika Sachdeva wrote: I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\"(\w+)\s(.*)\?(.*)\"/ ; my $uniq=$1; my $url=$4; chomp($uniq);chomp($url); my @var= (

RE: Perl Hash of arrays : comparison

2006-03-21 Thread Timothy Johnson
You need to dereference the array at $var{$key} in a similar way to the way you did it when you created the array, so something like this should work: foreach my $key(keys %VAR){ foreach my $element(@{$VAR{$key}}){ #do something... } } -Original Message- From: Sonika Sachdeva

Re: Perl Hash Question.

2005-06-24 Thread Xavier Noria
On Jun 24, 2005, at 5:07, Anthony Roe wrote: A = Reads URI from URIHASH. Visits site A. Parses all URIS on site A and for each URI found adds the URI to the URIHASH. A = Reads next URI from URIHASH. Visits site A. And so on... until the MAX URIHASH size is reached. My question is, is there