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

Perl hash

2015-07-30 Thread bikram behera
Hi Team, Please send me hash uses and concept Thanks, Bikram

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 referenc

Perl Hash concept.

2015-07-02 Thread bikram behera
Hi Team, Any body can explain me how to do perl hash refernce and dereference. Thanks, Bikram

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
7;c', '3], > ['d', 2], > ); > > To get the "value" for the element with the index 1 you need to do: > > my $value = $array[1][1]; #the value "2" > > and to get the "key" for the element with the index 1, you can do: > &g

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

2013-06-15 Thread Octavian Rasnita
and to get the "key" for the element with the index 1, you can do: my $key = $array[1][0]; #Will get "b" I don't know what you need to do... that's why I gave the idea of using arrays of arrays... --Octavian - Original Message - From: richard To: beginners@

perl hash loop: keys() vs values()

2013-06-15 Thread richard
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? Here is my test script; My perl is freebsd 5.8.9 use warnin

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

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

2011-04-03 Thread Wernher Eksteen
Hi, 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 emcpowera   sdbd sddg sdfj sdhm emcp

RE: store and edit perl hash data

2010-06-21 Thread Bob McConnell
From: Uri Guttman >> "pp" == philge philip writes: > > pp> is it possible to change values of my hash "%position_counts" > pp> stored in the file without retrieving it back using "fd_retrieve"? > > pp> if its not possible can you tell me how to store a huge hash data > pp> to a file or d

Re: store and edit perl hash data

2010-06-19 Thread Uri Guttman
> "pp" == philge philip writes: pp> is it possible to change values of my hash "%position_counts" pp> stored in the file without retrieving it back using "fd_retrieve"? pp> if its not possible can you tell me how to store a huge hash data pp> to a file or dbm and edit it without retr

Re: store and edit perl hash data

2010-06-19 Thread John W. Krahn
philge philip wrote: hi Hello, in the below script: use Storable qw(store_fd fd_retrieve); my %position_counts = ('name' => 'rahul'); open(OUT1, ">temp.txt"); store_fd(\%position_counts, *OUT1) || die "can't store to temp.txt\n"; close(OUT1); is it possible to change values of my hash

Re: store and edit perl hash data

2010-06-19 Thread Shlomi Fish
Hi, On Saturday 19 Jun 2010 12:56:36 philge philip wrote: > hi > > > in the below script: > > use Storable qw(store_fd fd_retrieve); > A few notes about your code. Please go over: http://perl.net.au/wiki/Freenode_Sharp_Perl_FAQ And: http://www.perlfoundation.org/perl5/index.cgi?ancient_per

store and edit perl hash data

2010-06-19 Thread philge philip
hi in the below script: use Storable qw(store_fd fd_retrieve); my %position_counts = ('name' => 'rahul'); open(OUT1, ">temp.txt"); store_fd(\%position_counts, *OUT1) || die "can't store to temp.txt\n"; close(OUT1); is it possible to change values of my hash "%position_counts" stored in the

Re: How to use a CGI/PERL hash variable in java script.

2010-02-07 Thread Peter Scott
On Mon, 01 Feb 2010 23:19:27 -0800, venu madhav wrote: > Hi All, > I've a situation where I create a hash variable in PERL and > use it in Java script which is embedded in the CGI. The key for that > hash is taken from JavaScript. For ex: > > - CGI code > my %hash{3}=300; > --

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Shlomi Fish
Hi Erez! On Tuesday 02 Feb 2010 15:20:16 Erez Schatz wrote: > On 2 February 2010 15:06, Shlomi Fish wrote: > > Ahmm... no. > > Are you physically unable to say anything in a social manner? > I apologise for writing my posts in a rude manner. See below for my response. > > <<< > > my %hash = (

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Erez Schatz
On 2 February 2010 15:06, Shlomi Fish wrote: > > Ahmm... no. Are you physically unable to say anything in a social manner? > > <<< > my %hash = (3 => <<"EOF"); > > > > > This is called a cross-site scripting attack ( > http://en.wikipedia.org/wiki/Cross-site_s

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Shlomi Fish
N module to pass and encode data to JavaScript. Regards, Shlomi Fish > > which would interpolate into whatever value is there at the hash. > However, if the "var1" variable is changing at the client, you will > need to send the value back to the server if you want to get

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Shlomi Fish
On Tuesday 02 Feb 2010 14:00:26 Erez Schatz wrote: > On 2 February 2010 13:46, Shlomi Fish wrote: > > Regarding "PERL" - it's either "perl" or "Perl" but never "PERL": > > > > http://perl.org.il/misc.html#pl_vs_pl > > What does have got to do with the question? > It doesn't, but it was a mista

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Erez Schatz
On 2 February 2010 09:19, venu madhav wrote: >        I've a situation where I create a hash variable in PERL and > use it in Java script which is embedded in the CGI. The key for that > hash is taken from JavaScript. For ex: > > - CGI code > my %hash{3}=300; > --JScript code--- > var

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Erez Schatz
On 2 February 2010 13:46, Shlomi Fish wrote: > Regarding "PERL" - it's either "perl" or "Perl" but never "PERL": > > http://perl.org.il/misc.html#pl_vs_pl What does have got to do with the question? > > Please go to http://perl-begin.org/ and find a good resource to learn Perl. To > qoute Mark J

Re: How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread Shlomi Fish
Hi Venu! On Tuesday 02 Feb 2010 09:19:27 venu madhav wrote: > Hi All, > I've a situation where I create a hash variable in PERL and > use it in Java script which is embedded in the CGI. The key for that > hash is taken from JavaScript. For ex: Regarding "PERL" - it's either "perl" or "Per

How to use a CGI/PERL hash variable in java script.

2010-02-02 Thread venu madhav
Hi All, I've a situation where I create a hash variable in PERL and use it in Java script which is embedded in the CGI. The key for that hash is taken from JavaScript. For ex: - CGI code my %hash{3}=300; --JScript code--- var var1 = 3; var variable = $hash{var1}; --

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
Sachdeva [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 21, 2006 4:53 PM To: beginners@perl.org Subject: Perl Hash of arrays : comparison Hi, I have Hash of array. I want to compare the array values within the hash. How can it be done? if ($eline =~ /$pattern/ ) { $eline =~ /(.*)\&quo

Perl Hash of arrays : comparison

2006-03-21 Thread Sonika Sachdeva
Hi, 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= ( split("&",$url) );

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi
Thanks to all who answered - I really appreciate the help! Now busy reading perldoc perlreftut ! Tony -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: Deprecated perl hash reference statement problem

2005-10-04 Thread Timothy Johnson
Tony Frasketi wrote: >Both $hash->{$key} and $$hash{$key} work fine and this also works >Although I'm not sure why ${$hash}{$key}. There is a reason for this. Let's say you had two variables: %hash (a hash) $hash (a hash reference) You could confuse the interpreter if you wrote this:

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Jeff 'japhy' Pinyan
On Oct 4, Tony Frasketi said: Both $hash->{$key} and $$hash{$key} work fine and this also works Although I'm not sure why ${$hash}{$key}. The reason ${$hash}{$key} works is because it's a generalization of $$hash{$key}. The rule of thumb is: 1. start with $HASH{key} 2. replace HASH wit

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi
Jeff 'japhy' Pinyan wrote: %hash->{$key} and @array->[$idx] are syntaces that you should not use. The fact that they work is due to intricacies of the Perl parser. Similarly, %{$hashref}->{$key} and @{$arrayref}->[$idx] are equally bad. Use $hash{$key} and $array[$idx] for normal hash and a

RE: Deprecated perl hash reference statement problem

2005-10-04 Thread Timothy Johnson
>Timothy Johnson wrote: > >>It depends on what you're trying to do. if $hashRef is a hash >>reference, then the correct syntax would be: >> >> $hashRef->{$key} = $value; >> >>or >> >> %{$hashRef}{$key} = $value; >> >>What you're saying below is something like: >> >>-- Take $hashRef and deref

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Jeff 'japhy' Pinyan
On Oct 4, Tony Frasketi said: sub get_form_data_1 { my($hashRef) = @_; my($buffer) = ""; my($key,$value,$pair,@pairs); if ($ENV{'REQUEST_METHOD'} eq "GET") { $buffer = $ENV{'QUERY_STRING'}; }else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); } @pairs = split(/&/, $buffer); for

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi
Timothy Johnson wrote: It depends on what you're trying to do. if $hashRef is a hash reference, then the correct syntax would be: $hashRef->{$key} = $value; or %{$hashRef}{$key} = $value; What you're saying below is something like: -- Take $hashRef and dereference it to %HASH1 (I'm giv

Re: Deprecated perl hash reference statement problem

2005-10-04 Thread Jeff 'japhy' Pinyan
On Oct 4, Tony Frasketi said: I've used the following statement in several instances before and never had any errors reported and the programs all seem to work ok. %{$hashRef}->{$key} = $value; %hash->{$key} and @array->[$idx] are syntaces that you should not use. The fact that they work i

RE: Deprecated perl hash reference statement problem

2005-10-04 Thread Timothy Johnson
m: Tony Frasketi [mailto:[EMAIL PROTECTED] Sent: Tuesday, October 04, 2005 11:33 AM To: beginners@perl.org Subject: Deprecated perl hash reference statement problem Hello Listers I've used the following statement in several instances before and never had any errors reported and the programs

Deprecated perl hash reference statement problem

2005-10-04 Thread Tony Frasketi
Hello Listers I've used the following statement in several instances before and never had any errors reported and the programs all seem to work ok. %{$hashRef}->{$key} = $value; But since I've began using use strict; use warnings; use diagnostics; in my programs, I'm now starting

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

Perl Hash Question.

2005-06-23 Thread Anthony Roe
Hi there everybody, I have a question and I am pretty stumped for the answer. I have a program that does the following: 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