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
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
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
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
> 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
>
>
>
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
"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,
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
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
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
$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
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
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
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
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
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?
>
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
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
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
> -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
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
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
>
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
;
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
= <>) =~ /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 ,
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
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
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
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
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]
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 $
>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
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
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]
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
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
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" =&
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
38 matches
Mail list logo