Re: array to hash array

2010-07-27 Thread C.DeRykus
On Jul 26, 3:22 am, sharan.basa...@gmail.com (Sharan Basappa) wrote: > Hi, > > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the el

Re: array to hash array

2010-07-26 Thread Teo
Dear Sharan, > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the element in the > array row as the key. > e.g. hash{ab} = cd ef

AW: array to hash array

2010-07-26 Thread Thomas Bätzler
Sharan Basappa asked: > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the element in the > array row as the key. > e.g. hash{ab

array to hash array

2010-07-26 Thread Sharan Basappa
Hi, Can someone tell me how to convert an array to hash. Each array entry has a row of values e.g. a(0) = ab cd ef; a(1) = mn de fg The hash array needs to be constructed with one of the element in the array row as the key. e.g. hash{ab} = cd ef - ab is a string in the array row

Re:read file in hash array

2008-10-08 Thread Jeff Pang
> Message du 08/10/08 12:56 > De : "[EMAIL PROTECTED]" > A : beginners@perl.org > Copie à : > Objet : read file in hash array > > > I want to ready file in Hash Array. > > I have file in following format: > > ID | Time | IP | Code > > >

read file in hash array

2008-10-08 Thread [EMAIL PROTECTED]
I want to ready file in Hash Array. I have file in following format: ID | Time | IP | Code open(INFO, $file); @lines = ; Instead of this I want to use Hash Array. May be just ID and IP fileds. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED

Re: find an entry in hash array

2008-03-20 Thread Dr.Ruud
"John W. Krahn" schreef: > my %hash; > > @hash{ @array } = (); Example: $ perl -MData::Dumper -wle ' my @array = qw/x t 3 u 77 y r/; my %hash; @hash{ @array } = (); print Dumper(\%hash); ' $VAR1 = { 'y' => undef,

Re: find an entry in hash array

2008-03-20 Thread John W. Krahn
my %hash; @hash{ @array } = (); John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [E

Re: find an entry in hash array

2008-03-20 Thread Chas. Owens
On Thu, Mar 20, 2008 at 12:05 PM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > ok. thats what I wanted to confirm. I my crude code, I was doing > exactly that and was > wondering if there is some other way to make an entry without really > adding value. > Maybe, perl has to do it internally but

Re: find an entry in hash array

2008-03-20 Thread Chas. Owens
On Thu, Mar 20, 2008 at 11:46 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > Can you throw some light on this statement: > > my %hashset = map { $_ => 1 } @array; snip The map* function takes a block of code and a list to process. It runs the block of code on every item in the list returning a l

Re: find an entry in hash array

2008-03-20 Thread Sharan Basappa
$hash{$_} = 1; > > > } > > -Original Message- > From: Sharan Basappa [mailto:[EMAIL PROTECTED] > Sent: 20 March 2008 15:47 > To: Chas. Owens > Cc: Robert Leibl; Perl Beginners > Subject: Re: find an entry in hash array > > Can you throw some light on th

RE: find an entry in hash array

2008-03-20 Thread Andrew Curry
008 15:47 To: Chas. Owens Cc: Robert Leibl; Perl Beginners Subject: Re: find an entry in hash array Can you throw some light on this statement: my %hashset = map { $_ => 1 } @array; On Thu, Mar 20, 2008 at 9:14 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 1

Re: find an entry in hash array

2008-03-20 Thread Sharan Basappa
Can you throw some light on this statement: my %hashset = map { $_ => 1 } @array; On Thu, Mar 20, 2008 at 9:14 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > On Thu, Mar 20, 2008 at 11:35 AM, Sharan Basappa > > <[EMAIL PROTECTED]> wrote: > > > Well here is what I am trying to do. > > I have an arr

Re: find an entry in hash array

2008-03-20 Thread Chas. Owens
On Thu, Mar 20, 2008 at 11:35 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > Well here is what I am trying to do. > I have an array (generated from somewhere) I would like to convert > this into an associative array and then based on some other input > I would like to see if an entry exists in

Re: find an entry in hash array

2008-03-20 Thread Sharan Basappa
1. But I never really use the value at all. Regards On Thu, Mar 20, 2008 at 8:56 PM, Robert Leibl <[EMAIL PROTECTED]> wrote: > Sharan Basappa wrote: > > Thanks. One more question. I really do not want to enter any value in > > a hash array. > > What is important is

Re: find an entry in hash array

2008-03-20 Thread Sharan Basappa
i am sorry. I really meant asso array .. On Thu, Mar 20, 2008 at 8:32 PM, Chas. Owens <[EMAIL PROTECTED]> wrote: > > On Thu, Mar 20, 2008 at 10:50 AM, Sharan Basappa > <[EMAIL PROTECTED]> wrote: > > Is there a way to find out if an entry exists in a hash array? >

Re: find an entry in hash array

2008-03-20 Thread Chas. Owens
On Thu, Mar 20, 2008 at 10:50 AM, Sharan Basappa <[EMAIL PROTECTED]> wrote: > Is there a way to find out if an entry exists in a hash array? > e.g. I have a hash array and another normal array. I would like loop > though regular array and see if the entries defined in this array e

find an entry in hash array

2008-03-20 Thread Sharan Basappa
Is there a way to find out if an entry exists in a hash array? e.g. I have a hash array and another normal array. I would like loop though regular array and see if the entries defined in this array exist in hash array. Regards -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands

Re: store more values in a hash array

2007-08-29 Thread Kermit Tensmeyer_semipublic
On Aug 27, 2:36 am, [EMAIL PROTECTED] (Andreas Moroder) wrote: > Hello, > > I have to store more then one value in a hash array. I tried to store a > array as value in the hash. But when I try to retrieve it I don't get the > array I have stored. > > Can anyone please

RE: store more values in a hash array

2007-08-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO
> -Original Message- > From: news [mailto:[EMAIL PROTECTED] On Behalf Of Andreas Moroder > Sent: Sunday, August 26, 2007 23:37 > To: beginners@perl.org > Subject: store more values in a hash array > > Hello, > > I have to store more then one value in a hash a

Re: store more values in a hash array

2007-08-27 Thread Paul Lalli
On Aug 27, 2:36 am, [EMAIL PROTECTED] (Andreas Moroder) wrote: > I have to store more then one value in a hash array. I tried to store a > array as value in the hash. But when I try to retriev it I don't get the > array I have stroed. > > Can anyone please help me. To re

Re: store more values in a hash array

2007-08-26 Thread Jeff Pang
27, Andreas Moroder <[EMAIL PROTECTED]>: > Hello, > > I have to store more then one value in a hash array. I tried to store a > array as value in the hash. But when I try to retriev it I don't get the > array I have stroed. > > Can anyone please help me. > > Thanks >

store more values in a hash array

2007-08-26 Thread Andreas Moroder
Hello, I have to store more then one value in a hash array. I tried to store a array as value in the hash. But when I try to retriev it I don't get the array I have stroed. Can anyone please help me. Thanks Andreas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional comman

Re: hash array

2006-02-15 Thread anand kumar
; my $age = $1 if ($_ = <>) =~ /AGE\s+(.*)$/; my $book = $1 if ($_ = <>) =~ /Book\s+(.*)$/; $hash{$name}->{age} = $age; $hash{$name}->{book} = $book; } } # then print the value -Original Message- From: anand kumar Sent: Feb 15, 2006 10:33 PM To: beginners@perl.org Su

Re: hash array

2006-02-15 Thread Jeff Pang
= <>) =~ /Book\s+(.*)$/; $hash{$name}->{age} = $age; $hash{$name}->{book} = $book; } } # then print the value -Original Message- From: anand kumar <[EMAIL PROTECTED]> Sent: Feb 15, 2006 10:33 PM To: beginners@perl.org Subject: Re: hash array Hi ,

Re: hash array

2006-02-15 Thread Tom Phoenix
On 2/15/06, anand kumar <[EMAIL PROTECTED]> wrote: > can anyone help me on how to store the data with hash key as the 'Name' > and the hash strings as the details of 'AGE' and 'Book' Perl's hashes use a single key to look up a single value. So, to keep this simple, you can use two hashes, %age

Re: hash array

2006-02-15 Thread anand kumar
Hi , Thanks for the reply. but can u help me out if the data is large and need a loop to store(also if possible give instructions if the record has variable or optional number of fields). Jeff Pang <[EMAIL PROTECTED]> wrote: Name ABC AGE 25 Book perl Name DEF AGE 20 Book linux Name GHI

Re: hash array

2006-02-15 Thread Jeff Pang
Name ABC AGE 25 Book perl Name DEF AGE 20 Book linux Name GHI AGE 21 Book PHP . can anyone help me on how to store the data with hash key as the 'Name' and the hash strings as the details of 'AGE' and 'Book' Hello,I think you could do it as followin

hash array

2006-02-15 Thread anand kumar
Hi all while learning hash arrays i have got a doubt i.e if the data is in the following manner Name ABC AGE 25 Book perl Name DEF AGE 20 Book linux Name GHI AGE 21 Book PHP . .. (assume that the above dat

Re: Arg... what about $#hash $#array

2002-09-20 Thread Sudarshan Raghavan
On Sun, 22 Sep 2002, Sudarshan Raghavan wrote: > my $hashcnt = keys(%hash) + values(%hash); Bad! my $hashcnt = keys(%hash) * 2; should do -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Arg... what about $#hash $#array

2002-09-20 Thread Sudarshan Raghavan
On Fri, 20 Sep 2002, Angerstein wrote: > I noticed if I want to print out the number of elements which should be > stored in $#hash, > but if i print it out i just get -1 !! $#array (assuming the variable array is a perl array) will give you the last index of @array. For number of elements my $

RE: Arg... what about $#hash $#array

2002-09-20 Thread nkuipers
>scalar (@array); >scalar (%hash); > >can be used to get the number of elements. For arrays, yes. For hashes, no. scalar %hash produces something that looks like this: 3/8, which is some measure of the number of buckets used by the hashing algo (efficiency). print scalar keys %hash, "\n"; w

AW: Arg... what about $#hash $#array

2002-09-20 Thread Angerstein
ok... scalar (@array); scalar (%hash); can be used to get the number of elements. > -Ursprüngliche Nachricht- > Von: Angerstein [mailto:[EMAIL PROTECTED]] > Gesendet am: Freitag, 20. September 2002 11:12 > An: [EMAIL PROTECTED] > Betreff: Arg... what about $#hash $#arra

Arg... what about $#hash $#array

2002-09-20 Thread Angerstein
I noticed if I want to print out the number of elements which should be stored in $#hash, but if i print it out i just get -1 !! What else can i do??? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

RE: question regarding hash hash hash array

2001-12-27 Thread Hanson, Robert
b'}{'c'} eq 'ARRAY' ) { die "Error! Not an array ref!"; } Rob -Original Message- From: dodda satish [mailto:[EMAIL PROTECTED]] Sent: Wednesday, December 26, 2001 6:39 PM To: [EMAIL PROTECTED] Subject: question regarding hash hash hash array Hi , I hav

question regarding hash hash hash array

2001-12-26 Thread dodda satish
Hi , I have declared a hash hash hash array as $::alpha{'a'}{'b'}{'c'}=['p','q','r']; and when I do to put these in a local variable array as @::my_array=@{$::alpha{'a'}{'b'}{'c'} }; I get the values of

Re: hash array of arrays?

2001-07-29 Thread Jos I. Boumans
just dereference it: foo( @{ $R{"first"} } ); it's as easy as that =) hth Jos Boumans > > Hi all, > > here's my question :): > > I define a hash array: > our %R=("first" => [ "one", "two" ], "second" =&

hash array of arrays?

2001-07-29 Thread Pozsar Balazs
Hi all, here's my question :): I define a hash array: our %R=("first" => [ "one", "two" ], "second" => ["third", "fourth"]); Now I can get back back array references from this using: $R{"first"} I also can get b