Fwd: slice of an arrayref

2010-10-29 Thread shawn wilson
that all works fine (exept my many to many problem i noted above). my issue is how to print out a slice of an arrayref of a hashref? my underlying problem (i think) is that there has got to be a better way? i've got half a mind to create a temp table in the db to do this, but that doesn't s

Re: arrayref

2008-07-08 Thread Rob Dixon
elavazhagan perl wrote: > Hi.. > > Thanks Rob,with ur code ,Now I can display all the countries with > regions.Now i would like to display only countries specific to the region. > We can split the data and assign into two different arrays.Let me know is > there any specific way to retrive the

RE: arrayref

2008-07-08 Thread Stewart Anderson
08 12:00 To: Dr.Ruud; [EMAIL PROTECTED] Cc: beginners@perl.org Subject: Re: arrayref Hi.. Thanks Rob,with ur code ,Now I can display all the countries with regions.Now i would like to display only countries specific to the region. We can split the data and assign into two different arrays.Let

Re: arrayref

2008-07-08 Thread elavazhagan perl
Hi.. Thanks Rob,with ur code ,Now I can display all the countries with regions.Now i would like to display only countries specific to the region. We can split the data and assign into two different arrays.Let me know is there any specific way to retrive the data ?? Thanks a lot #!

Re: arrayref

2008-07-08 Thread Dr.Ruud
"elavazhagan perl" schreef: > #Start > #! /usr/local/perl/bin > use strict; The shebang-line should be the first one. "use warnings;" is missing. -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://l

Re: arrayref

2008-07-07 Thread Rob Dixon
elavazhagan perl wrote: > > Please have a glance on the following code and suggest me to purify it. > My requirement is when the user choose the region,I need to display the > countries specific to that regions. > I have been trying in both hash and array references.This one is

arrayref

2008-07-07 Thread elavazhagan perl
Hi, Please have a glance on the following code and suggest me to purify it. My requirement is when the user choose the region,I need to display the countries specific to that regions. I have been trying in both hash and array references.This one is for arrayref. I have already the values of

Re: looping over arrayref of hashes

2008-06-20 Thread Rob Dixon
Graeme McLaren wrote: > Hi all, I'm in need of a loop, can't seem to find what I'm looking for > online. I want to loop over this array ref inserting each hash value into > the DB at each iteration.I've got the following data structure which is > assigned to $aref: > > my $VAR1 = [ > { >

Re: looping over arrayref of hashes

2008-06-19 Thread Narthring
On Jun 18, 11:27 am, [EMAIL PROTECTED] (Graeme McLaren) wrote: > Hi all, I'm in need of a loop, can't seem to find what I'm looking for > online.  I want to loop over this array ref inserting each hash value into > the DB at each iteration.I've got the following data structure which is > assigne

Re: looping over arrayref of hashes

2008-06-18 Thread Amit Saxena
Hi On the basis of what you have mentioned, I have made a sample code. Let me know if my understanding is different from yours. The Perl Code is copied below :- # cat u.pl #!/usr/bin/perl ##!/u01/app/oracle/product/10.1.0/db_1/perl/bin/perl # # Hi all, I'm in need of a loop, can't seem to fin

Re: looping over arrayref of hashes

2008-06-18 Thread Gunnar Hjalmarsson
Graeme McLaren wrote: Hi all, I'm in need of a loop, can't seem to find what I'm looking for online. I want to loop over this array ref inserting each hash value into the DB at each iteration.I've got the following data structure which is assigned to $aref: $VAR1 = [ {

Re: looping over arrayref of hashes

2008-06-18 Thread Rodrick Brown
On Wed, Jun 18, 2008 at 12:27 PM, Graeme McLaren < [EMAIL PROTECTED]> wrote: > > Hi all, I'm in need of a loop, can't seem to find what I'm looking for > online. I want to loop over this array ref inserting each hash value into > the DB at each iteration.I've got the following data structure whic

looping over arrayref of hashes

2008-06-18 Thread Graeme McLaren
Hi all, I'm in need of a loop, can't seem to find what I'm looking for online. I want to loop over this array ref inserting each hash value into the DB at each iteration.I've got the following data structure which is assigned to $aref: $VAR1 = [ {'rate' => '1.98',

Re: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
ECTED]] > > Sent: Wednesday, July 10, 2002 12:26 PM > > To: Timothy Johnson; [EMAIL PROTECTED] > > Cc: Shawn; Connie Chan; [EMAIL PROTECTED] > > Subject: more example code Re: help dereferencing arrayref so > > I can put > > the value into a hash > &g

Re: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
dereference an already dereferenced arrayref? zack "Bob Showalter" <[EMAIL PROTECTED]> wrote in message 2E4528861499D41199D200A0C9B15BC031BBA6@FRISTX">news:2E4528861499D41199D200A0C9B15BC031BBA6@FRISTX... > > -Original Message- > > From: Zachary Buckh

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >you get a warning with @x[2] if 'x' is an array, >but no warning with @$x[2] where 'x' is an array ref. >so perl isn't handling quite the same. Well, let me refer to the source. toke.c is where the "scalar value @x[1] better written as $x[1]" comes from. To raise

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:05 AM, Jeff 'japhy' Pinyan wrote: > On Jul 10, bob ackerman said: > >> and, as someone pointed out, this does work: >> $x = ['abc','def','ghi']; >> print @$x[2]."\n"; # prints 'ghi' >> >> but i couldn't tell you how perl reads this, except to say that '@

RE: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Timothy Johnson
>Am I alone in thinking that $x->[2] is much more readable that @$x[2] or $$x[2]? IMHO, you are just asking for trouble whenever you use notation like "$$x[2]". You should always put the curly braces around the scalar being dereferenced to be sure that you or someone reading your code doesn't

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >> All lists get auto-cast into a scalar, in scalar context. An array slice >> is merely a list of array elements. >> >> $x = @y[2]; >> >> is the same as >> >> $x = ($y[2]); > >except you will get warnings on these lines. Perl warns about @x[$i] because it was

RE: more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Bob Showalter
> -Original Message- > From: Zachary Buckholz [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, July 10, 2002 12:26 PM > To: Timothy Johnson; [EMAIL PROTECTED] > Cc: Shawn; Connie Chan; [EMAIL PROTECTED] > Subject: more example code Re: help dereferencing arrayref so >

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:39 AM, Jeff 'japhy' Pinyan wrote: > On Jul 10, George Schlossnagle said: > >> Am I alone in thinking that $x->[2] is much more readable that @$x[2] >> or $$x[2]? > > No; I always use the $ref->... syntax, unless I'm golfing. > >> @b[2] is an array slice with

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, George Schlossnagle said: >Am I alone in thinking that $x->[2] is much more readable that @$x[2] >or $$x[2]? No; I always use the $ref->... syntax, unless I'm golfing. >@b[2] is an array slice with a single element (which strangely seems to >get auto-cast as a scalar). All lists

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 09:29 AM, George Schlossnagle wrote: >> and, as someone pointed out, this does work: >> $x = ['abc','def','ghi']; >> print @$x[2]."\n"; # prints 'ghi' > > > Am I alone in thinking that $x->[2] is much more readable that @$x[2] > or $$x[2]? i was only sa

more example code Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Zachary Buckholz
s); } sub get_pct_up_time($sum_checks, $sum_errors) { my $sum_checks = $_[0]; my $sum_errors = $_[1]; my @pct_up_time; for(my $i = 0; $i <= 6; $i++) { if(@$sum_checks[$i] == 0) {next;}; my $sum_good = @$sum_checks[$i] - @$sum_errors[$i]; $pct_up_time[$i] = (($sum_good * 100) /

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread George Schlossnagle
> and, as someone pointed out, this does work: > $x = ['abc','def','ghi']; > print @$x[2]."\n"; # prints 'ghi' Am I alone in thinking that $x->[2] is much more readable that @$x[2] or $$x[2]? > > but i couldn't tell you how perl reads this, except to say that '@$x' > dereferences and

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Jeff 'japhy' Pinyan
On Jul 10, bob ackerman said: >and, as someone pointed out, this does work: >$x = ['abc','def','ghi']; >print @$x[2]."\n"; # prints 'ghi' > >but i couldn't tell you how perl reads this, except to say that '@$x' >dereferences and then '[2]' gets the array element. >but i don't know why a '$

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread bob ackerman
On Wednesday, July 10, 2002, at 01:31 AM, Janek Schleicher wrote: > Shawn wrote at Wed, 10 Jul 2002 09:59:54 +0200: > >> I think what you are looking for is: >> $avg_resp_time->[0] >> >> if you want to have the '@' at the front, I think you would need >> something like this: >> @{$avg_resp_t

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Janek Schleicher
Shawn wrote at Wed, 10 Jul 2002 09:59:54 +0200: > I think what you are looking for is: > $avg_resp_time->[0] > > if you want to have the '@' at the front, I think you would need something like this: > @{$avg_resp_time}[0] > What should be better written as ${$avg_resp_time}[0] if you want to

RE: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Timothy Johnson
s: $avg_resp_time is an array reference. Get the first element of the dereferenced array. ## -Original Message- From: Zachary Buckholz [mailto:[EMAIL PROTECTED]] Sent: Tuesday, July 09, 2002 11:31 PM To: [EMAIL PROTECTED] Subject: help derefe

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Shawn
"Zachary Buckholz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I understand how to use a foreach on a reference to an array as follows: > > my $avg_resp_time = get_avg_resp_time($durations, $url_id); > foreach my $avg_resp(@$avg_resp_time) { > print

Re: help dereferencing arrayref so I can put the value into a hash

2002-07-10 Thread Connie Chan
> But how do I directly access one array value from the reference to the > array? > > print "DEBUG TEST @$avg_resp_time[0]\n";Fails > print "DEBUG TEST @$avg_resp_time->[0]\n";Fails > print "DEBUG TEST @{$avg_resp_time[0]}\n";Fails > Why don't just print "DEBUG TEST $avg_resp_time

RE: help dereferencing arrayref so I can put the value into a hash

2002-07-09 Thread Toby Stuart
2002 4:31 PM To: [EMAIL PROTECTED] Subject: help dereferencing arrayref so I can put the value into a hash I understand how to use a foreach on a reference to an array as follows: my $avg_resp_time = get_avg_resp_time($durations, $url_id); foreach my $avg_resp(@$avg_resp_time) { print

help dereferencing arrayref so I can put the value into a hash

2002-07-09 Thread Zachary Buckholz
I understand how to use a foreach on a reference to an array as follows: my $avg_resp_time = get_avg_resp_time($durations, $url_id); foreach my $avg_resp(@$avg_resp_time) { print "AVG = $avg_resp\n"; } But how do I directly access one array value from the reference to the array? print "