Re: Need explanation of code

2015-04-12 Thread shawn wilson
On Apr 12, 2015 8:06 AM, "Shawn H Corey" wrote: > > On Sat, 11 Apr 2015 21:20:22 -0700 > SSC_perl wrote: > > > Could someone please explain the difference between: > > > > %{$self->{'DATA'}} = () } > > %{ $self->{'DATA'} } = (); > > > > > and > > > > $self->{'DATA'} = {} > > > > I w

Re: Need explanation of code

2015-04-12 Thread Shawn H Corey
On Sat, 11 Apr 2015 21:20:22 -0700 SSC_perl wrote: > Could someone please explain the difference between: > > %{$self->{'DATA'}} = () } %{ $self->{'DATA'} } = (); > > and > > $self->{'DATA'} = {} > > I was told that they are equivalent, but they're not. One > works and the ot

Re: Need explanation of code

2015-04-12 Thread Andrew Solomon
Eeeks, Sorry Shlomi, I can't help thinking my German lessons have been counter-productive... A On Sun, Apr 12, 2015 at 10:37 AM, Shlomi Fish wrote: > On Sun, 12 Apr 2015 09:36:00 +0100 > Andrew Solomon wrote: > > > Thank you very much Schlomi - I stand corrected! > > > > You're welcome, Andrew

Re: Need explanation of code

2015-04-12 Thread Shlomi Fish
On Sun, 12 Apr 2015 09:36:00 +0100 Andrew Solomon wrote: > Thank you very much Schlomi - I stand corrected! > You're welcome, Andrew! Just note that my name is spelled "Shlomi" - not "Schlomi". See: * http://www.shlomifish.org/meta/FAQ/#your_name You can also call me "Rindolf": http://www.sh

Re: Need explanation of code

2015-04-12 Thread Andrew Solomon
Thank you very much Schlomi - I stand corrected! Frank, another way of putting what Schlomi has illustrated is that: %{$self->{'DATA'}} = ( foo => 'bar' ); means "change the contents of the hash which $self->{'DATA'} refers to", while $self->{'DATA'} = { foo => 'bar' }; means "change $self->{'

Re: Need explanation of code

2015-04-12 Thread Shlomi Fish
Hi Andrew, On Sun, 12 Apr 2015 07:25:55 +0100 Andrew Solomon wrote: > Hi Frank > > I found the first one rather obscure, but they are equivalent. No - they are not exactly the same. See below: > To prove > this, Data::Dumper is my friend: > > #!/usr/bin/perl > > use strict; > use warnings;

Re: Need explanation of code

2015-04-11 Thread Shlomi Fish
On Sat, 11 Apr 2015 21:20:22 -0700 SSC_perl wrote: > Could someone please explain the difference between: > > %{$self->{'DATA'}} = () } > > and > > $self->{'DATA'} = {} The first line works on the physical reference $self->{'DATA'} and empties it. The second one assigns a new empty refe

Re: Need explanation of code

2015-04-11 Thread Andrew Solomon
Hi Frank I found the first one rather obscure, but they are equivalent. To prove this, Data::Dumper is my friend: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; { my $self; print "selfish self \n"; %{$self->{'DATA'}} = ( foo => 'bar' ); print Dumper $self; } { my $self;

Re: Need explanation of code

2015-04-11 Thread shawn wilson
On Apr 12, 2015 12:23 AM, "SSC_perl" wrote: > > Could someone please explain the difference between: > > %{$self->{'DATA'}} = () } > The hashref of key "DATA" equals an empty list. The trailing bracket is the end of the else block. $self is also probably blessed (an object). ref($self->{

Need explanation of code

2015-04-11 Thread SSC_perl
Could someone please explain the difference between: %{$self->{'DATA'}} = () } and $self->{'DATA'} = {} I was told that they are equivalent, but they're not. One works and the other doesn't, so they must be different. Here's the context: sub empty_db {

Re: Need explanation of expression

2013-11-18 Thread Angela Barone
> Specifically, http://perldoc.perl.org/perlop.html#Conditional-Operator > > '?:' is otherwise known as the 'ternary conditional operator' -- if > you don't know that bit of esoterica, finding the right documentation > is a lot harder. 8^) Thank you, everyone! It's a lot clearer to me n

Re: Need explanation of expression

2013-11-18 Thread Shawn H Corey
On Mon, 18 Nov 2013 12:14:05 -0800 Angela Barone wrote: > Could someone explain the format of the following line and how to > read it? > > $name = $fieldname =~ /\[(.*?)\]/ ? $main::global->{'form'}->{$1} : > $out; It means: if( $fieldname =~ /\[(.*?)\]/ ){ $name = $main::global->{'form

Re: Need explanation of expression

2013-11-18 Thread John SJ Anderson
On Mon, Nov 18, 2013 at 12:34 PM, John W. Krahn wrote: >> Also, is there something in the perl man pages about it? > > > Yes. You probably want perlop? Specifically, http://perldoc.perl.org/perlop.html#Conditional-Operator '?:' is otherwise known as the 'ternary conditional operator' -

Re: Need explanation of expression

2013-11-18 Thread John W. Krahn
Angela Barone wrote: Hello, Hello, Could someone explain the format of the following line and how to read it? $name = $fieldname =~ /\[(.*?)\]/ ? $main::global->{'form'}->{$1} : $out; Do the contents of $fieldname match the pattern /\[(.*?)\]/? If they do then assign $main::g

Need explanation of expression

2013-11-18 Thread Angela Barone
Hello, Could someone explain the format of the following line and how to read it? $name = $fieldname =~ /\[(.*?)\]/ ? $main::global->{'form'}->{$1} : $out; Also, is there something in the perl man pages about it? Thank you, Angela -- To unsubscribe, e-mail: beginners-unsubs

Re: need explanation

2010-07-18 Thread Chas. Owens
On Jul 17, 2010, at 10:01, "Dr.Ruud" wrote: > Vishal Gupta wrote: > > Sharan asked: > > >> my @table = @{ $tableRef }; > >> >>> 2) what does @table contain? >> @table will contains the original array, which is referenced by "$tableRef". > > Be more careful: it contains a copy. snip More spec

Re: need explanation

2010-07-18 Thread Dr.Ruud
Vishal Gupta wrote: > Sharan asked: >> my @table = @{ $tableRef }; >> 2) what does @table contain? @table will contains the original array, which is referenced by "$tableRef". Be more careful: it contains a copy. -- Ruud -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additio

Re: need explanation

2010-07-16 Thread Chas. Owens
On Fri, Jul 16, 2010 at 10:18, Shawn H Corey wrote: > On 10-07-16 08:17 AM, Chas. Owens wrote: >> >> So it can get bad: >> >> my $ref = \\[1]; >> print @$$$ref, "\n"; snip > If you have something that complicated, it's going to be bad not matter how > you do it. snip Yeah, at a time like

Re: need explanation

2010-07-16 Thread Shawn H Corey
On 10-07-16 08:17 AM, Chas. Owens wrote: So it can get bad: my $ref = \\[1]; print @$$$ref, "\n"; but I fail to see how print @{${${${${${${$ref}}}, "\n"; or even worse print @{ ${ ${ ${ ${ ${ ${ $ref } } } } } } }, "\n"; makes that any better. If you have something that compl

Re: need explanation

2010-07-16 Thread Chas. Owens
On Fri, Jul 16, 2010 at 06:15, Rob Coops wrote: snip > Yes it is the same but for readability reasons is better to use the @{} > solution. Think about a complex structure you could get something like > @%$variable which looks more like you are cursing cartoon style > then writing code certainly if

Re: need explanation

2010-07-16 Thread Rob Coops
On Fri, Jul 16, 2010 at 12:06 PM, Sharan Basappa wrote: > Thanks, Vishal. > > I was confused with usage {}. So you are saying that it will > dereference the array. > Isn't @$tableRef not enough in that case? > > Regards, > Sharan > > > On Fri, Jul 16, 2010 at 3:33 PM, Vishal Gupta > wrote: > > Hi

RE: need explanation

2010-07-16 Thread Vishal Gupta
Ya Sharan, @$tableRef is also enough in this case. But as we know, there are many ways to do a single job in Perl... so we can use either ways also. Regards, Vishal > Date: Fri, 16 Jul 2010 15:36:25 +0530 > Subject: Re: need explanation > From: sharan.basa...@gmail.com > To:

Re: need explanation

2010-07-16 Thread John W. Krahn
Sharan Basappa wrote: Folks, Hello, I am putting a line of code which I am not able to clearly understand. This is a reuse ... my(@table) = @{$tableRef}; The tableRef is returned as a reference after reading a file that contains record. Two questions: 1) what does @{$tableRef} really do?

Re: need explanation

2010-07-16 Thread Sharan Basappa
Thanks, Vishal. I was confused with usage {}. So you are saying that it will dereference the array. Isn't @$tableRef not enough in that case? Regards, Sharan On Fri, Jul 16, 2010 at 3:33 PM, Vishal Gupta wrote: > Hi Sharan, > > Please find below the answers: > > 1) what does @{$tableRef} reall

RE: need explanation

2010-07-16 Thread Vishal Gupta
Hi Sharan, Please find below the answers: 1) what does @{$tableRef} really do? This will de-reference the "$tableRef", which is suppose to be an array reference. 2) what does @table contain? @table will contains the original array, which is referenced by "$tableRef". Regards, Vishal

need explanation

2010-07-16 Thread Sharan Basappa
Folks, I am putting a line of code which I am not able to clearly understand. This is a reuse ... my(@table) = @{$tableRef}; The tableRef is returned as a reference after reading a file that contains record. Two questions: 1) what does @{$tableRef} really do? 2) what does @table contain? Regard

Re: Need explanation about this code.

2009-10-09 Thread Raheel Hassan
Thanks Rob, Jim and all others who helped me in explaining this code. On Fri, Oct 9, 2009 at 1:06 PM, Rob Coops wrote: > > > On Fri, Oct 9, 2009 at 9:58 AM, Raheel Hassan wrote: > >> Thanks Jim for a nice reply, could you explain what >> push(@$temp_table,$ref->[$i]); is doing. in the first code

Re: Need explanation about this code.

2009-10-09 Thread Rob Coops
On Fri, Oct 9, 2009 at 9:58 AM, Raheel Hassan wrote: > Thanks Jim for a nice reply, could you explain what > push(@$temp_table,$ref->[$i]); is doing. in the first code. > > In the second @_= $dbh where as in the if command $_ is getting the values > from this default array. Then how it can return

Re: Need explanation about this code.

2009-10-09 Thread Raheel Hassan
Thanks Jim for a nice reply, could you explain what push(@$temp_table,$ref->[$i]); is doing. in the first code. In the second @_= $dbh where as in the if command $_ is getting the values from this default array. Then how it can return \%s..in the last statement. On Thu, Oct 8, 2009 at 6

Re: Need explanation about this code.

2009-10-08 Thread John W. Krahn
Raheel Hassan wrote: Hello, Hello, I have problems in understanding $...@$ use ? 1- my $ref = $$temp_sth -> fetchall_arrayref({}); for(my $i=0; $i <= $...@$ref}; $i++) { push(@$temp_table,$ref->[$i]);} $...@$ref} should be $#{$ref} or simply $#$ref And for(my $i=0; $i <= $...

Re: Need explanation about this code.

2009-10-08 Thread Jim Gibson
On 10/8/09 Thu Oct 8, 2009 9:00 AM, "Raheel Hassan" scribbled: > Hello, > > I have problems in understanding $...@$ use ? > > 1- my $ref = $$temp_sth -> fetchall_arrayref({}); > for(my $i=0; $i <= $...@$ref}; $i++) { For any array @a, the largest index is given by $#a. $ref is a ref

Need explanation about this code.

2009-10-08 Thread Raheel Hassan
Hello, I have problems in understanding $...@$ use ? 1- my $ref = $$temp_sth -> fetchall_arrayref({}); for(my $i=0; $i <= $...@$ref}; $i++) { push(@$temp_table,$ref->[$i]);} Can some one explain the under given function. 2- sub buildSensorsHashtable { my ($dbh) = @_; my $e