need explanation
Folks,
I am putting a line of code which I am not able to clearly understand.
This is a reuse ...
my( [at] table) = [at] {$tableRef};
The tableRef is returned as a reference after reading a file that
contains record.
Two questions:
1) what does [at] {$tableRef} really do?
2) what does [at] table contain?
Regards,
Sharan
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
RE: need explanation
--_872b63b1-9bdb-4e7c-9c2f-17ac94a1f263_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Sharan=2C
Please find below the answers:
1) what does [at] {$tableRef} really do?
This will de-reference the "$tableRef"=2C which is suppose to be an array r=
eference.
2) what does [at] table contain?
[at] table will contains the original array=2C which is referenced by "$tableRe=
f".
Regards=2C
Vishal
____________________________________________________________ _____
Bollywood=2C beauties and the latest flicks on MSN entertainment
http://entertainment.in.msn.com/=
--_872b63b1-9bdb-4e7c-9c2f-17ac94a1f263_--
Re: need explanation
Thanks, Vishal.
I was confused with usage {}. So you are saying that it will
dereference the array.
Isn't [at] $tableRef not enough in that case?
Regards,
Sharan
On Fri, Jul 16, 2010 at 3:33 PM, Vishal Gupta
<vishal.knit2007 [at] hotmail.com> wrote:
> Hi Sharan,
>
> Please find below the answers:
>
> 1) what does [at] {$tableRef} really do?
>
> This will de-reference the "$tableRef", which is suppose to be an array
> reference.
>
> 2) what does [at] table contain?
>
> [at] table will contains the original array, which is referenced by "$tableRef".
>
> Regards,
> Vishal
> ________________________________
> Manage your finance and manage money through MSN Money Special Drag n' drop
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: need explanation
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( [at] table) = [at] {$tableRef};
>
> The tableRef is returned as a reference after reading a file that
> contains record.
> Two questions:
> 1) what does [at] {$tableRef} really do?
[at] { } de-references the array reference contained in $tableRef.
> 2) what does [at] table contain?
A copy of the data from the original array that $tableRef refereneces.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
RE: need explanation
--_ed49917e-94d9-4893-99e2-058ed8c01d20_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Ya Sharan=2C
[at] $tableRef is also enough in this case. But as we know=2C there are many wa=
ys to do a single job in Perl... so we can use either ways also.
Regards=2C
Vishal
> Date: Fri=2C 16 Jul 2010 15:36:25 +0530
> Subject: Re: need explanation
> From: sharan.basappa [at] gmail.com
> To: vishal.knit2007 [at] hotmail.com
> CC: beginners [at] perl.org
>
> Thanks=2C Vishal.
>
> I was confused with usage {}. So you are saying that it will
> dereference the array.
> Isn't [at] $tableRef not enough in that case?
>
> Regards=2C
> Sharan
>
>
> On Fri=2C Jul 16=2C 2010 at 3:33 PM=2C Vishal Gupta
> <vishal.knit2007 [at] hotmail.com> wrote:
> > Hi Sharan=2C
> >
> > Please find below the answers:
> >
> > 1) what does [at] {$tableRef} really do?
> >
> > This will de-reference the "$tableRef"=2C which is suppose to be an arr=
ay
> > reference.
> >
> > 2) what does [at] table contain?
> >
> > [at] table will contains the original array=2C which is referenced by "$tab=
leRef".
> >
> > Regards=2C
> > Vishal
> > ________________________________
> > Manage your finance and manage money through MSN Money Special Drag n' =
drop
>
> --
> To unsubscribe=2C e-mail: beginners-unsubscribe [at] perl.org
> For additional commands=2C e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
____________________________________________________________ _____
The world on four wheels in MSN Autos
http://autos.in.msn.com/=
--_ed49917e-94d9-4893-99e2-058ed8c01d20_--
Re: need explanation
--0016364990a1549dae048b7e7f94
Content-Type: text/plain; charset=UTF-8
On Fri, Jul 16, 2010 at 12:06 PM, Sharan Basappa
<sharan.basappa [at] gmail.com>wrote:
> Thanks, Vishal.
>
> I was confused with usage {}. So you are saying that it will
> dereference the array.
> Isn't [at] $tableRef not enough in that case?
>
> Regards,
> Sharan
>
>
> On Fri, Jul 16, 2010 at 3:33 PM, Vishal Gupta
> <vishal.knit2007 [at] hotmail.com> wrote:
> > Hi Sharan,
> >
> > Please find below the answers:
> >
> > 1) what does [at] {$tableRef} really do?
> >
> > This will de-reference the "$tableRef", which is suppose to be an array
> > reference.
> >
> > 2) what does [at] table contain?
> >
> > [at] table will contains the original array, which is referenced by
> "$tableRef".
> >
> > Regards,
> > Vishal
> > ________________________________
> > Manage your finance and manage money through MSN Money Special Drag n'
> drop
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>
Hi Sharan,
Yes it is the same but for readability reasons is better to use the [at] {}
solution. Think about a complex structure you could get something like
[at] %$variable which looks more like you are cursing cartoon style
then writing code certainly if the data structure gets a little more complex
then that.
So in nice looking code and for prosperity (you will not believe how long
some scripts can remain in use, they can quite often remain in use many
years after you stop working for a company) we should as smart perl coders
always use the cleaner looking and easier to read [at] { %{ $variable } } } even
though the other way might save a few key strokes.
Regards,
Rob
--0016364990a1549dae048b7e7f94--
Re: need explanation
On Fri, Jul 16, 2010 at 06:15, Rob Coops <rcoops [at] gmail.com> wrote:
snip
> Yes it is the same but for readability reasons is better to use the [at] {}
> solution. Think about a complex structure you could get something like
> [at] %$variable which looks more like you are cursing cartoon style
> then writing code certainly if the data structure gets a little more complex
> then that.
snip
No you won't. % [at] $varname is not valid Perl 5, it isn't even valid
Perl 6. The only thing that can ever be dereferenced is a scalar
value. So it can get bad:
my $ref = \\\\\\[1];
print [at] $$$$$$$ref, "\n";
but I fail to see how
print [at] {${${${${${${$ref}}}}}}}, "\n";
or even worse
print [at] { ${ ${ ${ ${ ${ ${ $ref } } } } } } }, "\n";
makes that any better. The purpose of ${}, [at] {}, and %{} is to handle
cases where just [at] or % would not do what you mean. For instance,
my [at] a = ([5]);
my $x = $$a[0]; #bad, doesn't do what you mean
my $y = ${$a[0]}; #good
This is one of the places I disagree with [Perl Best Practices][0] and
consequently [Perl::Critic][1] (although you have to turn it up to
brutal to get it to complain).
The better rule is to use braces when dealing with an expresion that
is more complex than just a variable name.
[0]: http://oreilly.com/catalog/9780596001735
[1]: http://search.cpan.org/dist/Perl-Critic/lib/Perl/Critic.pm
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: need explanation
On 10-07-16 08:17 AM, Chas. Owens wrote:
> So it can get bad:
>
> my $ref = \\\\\\[1];
> print [at] $$$$$$$ref, "\n";
>
> but I fail to see how
>
> print [at] {${${${${${${$ref}}}}}}}, "\n";
>
> or even worse
>
> print [at] { ${ ${ ${ ${ ${ ${ $ref } } } } } } }, "\n";
>
> makes that any better.
If you have something that complicated, it's going to be bad not matter
how you do it.
--
Just my 0.00000002 million dollars worth,
Shawn
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early & often.
Eliminate software piracy: use only FLOSS.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: need explanation
On Fri, Jul 16, 2010 at 10:18, Shawn H Corey <shawnhcorey [at] gmail.com> wrote:
> On 10-07-16 08:17 AM, Chas. Owens wrote:
>>
>> So it can get bad:
>>
>> my $ref = \\\\\\[1];
>> print [at] $$$$$$$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 that it might be a good idea to throw efficiency
to the wind and say something like
my $some_meaningful_name = $$ref;
my $other_meaningful_name = $$some_meaningful_name;
..
..
..
--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: need explanation
Vishal Gupta wrote:
> Sharan asked:
>> my [at] table = [at] { $tableRef };
>>
>> 2) what does [at] table contain?
>
> [at] table will contains the original array, which is referenced by "$tableRef".
Be more careful: it contains a copy.
--
Ruud
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: need explanation
On Jul 17, 2010, at 10:01, "Dr.Ruud" <rvtol+usenet [at] isolution.nl> wrote:
> Vishal Gupta wrote:
> > Sharan asked:
>
> >> my [at] table =3D [at] { $tableRef };
> >>
>>> 2) what does [at] table contain?
>> [at] table will contains the original array, which is referenced by "$tableRe=
f".
>
> Be more careful: it contains a copy.
snip
More specifically a shallow copy.=
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/