Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   The meaning of @ (http://www.velocityreviews.com/forums/t891076-the-meaning-of.html)

Leslie Viljoen 02-27-2005 10:09 AM

The meaning of @
 
Hello!

I have been trying to figure out one of Abigail's JAPH
signatures (check http://www.cpan.org/misc/japh):

#!/usr/bin/perl -lw
eval {die [[qq [Just another Perl Hacker]]]};;
print
${${${@}}[$#{@{${@}}}]}
[$#{${@{${@}}}
[$#{@{${@}}}]}]

This is the center of the expression in a few places: ${@}
Are we dereferencing the @? What does the @ on its own mean?
The Programming Perl manual I have makes no reference to this
shorthand and Google and Altavista don't seem to search on
punctuation.

I have tried printing ${@} and @, but I get nothing.
Presumeably the die puts the error message in the @ in some
format.

Can someone please explain?

Les

GreenLeaf 02-27-2005 10:30 AM

Re: The meaning of @
 
Leslie Viljoen wrote:
> Hello!
>
> I have been trying to figure out one of Abigail's JAPH
> signatures (check http://www.cpan.org/misc/japh):
>
> Can someone please explain?
>
> Les


Didn't she answer this same question from you once, a few days back? :o)


Fabian Pilkowski 02-27-2005 12:23 PM

Re: The meaning of @
 
Leslie Viljoen schrieb:
>
> I have been trying to figure out one of Abigail's JAPH
> signatures (check http://www.cpan.org/misc/japh):
>
> #!/usr/bin/perl -lw
> eval {die [[qq [Just another Perl Hacker]]]};;
> print
> ${${${@}}[$#{@{${@}}}]}
> [$#{${@{${@}}}
> [$#{@{${@}}}]}]
>
> This is the center of the expression in a few places: ${@}
> Are we dereferencing the @? What does the @ on its own mean?
> The Programming Perl manual I have makes no reference to this
> shorthand and Google and Altavista don't seem to search on
> punctuation.


In Perl, you can write a var $foo as ${foo}. In some situations this
will be a handy abbrev e.g. in "${foo}bar" instead of $foo.'bar'. So
your questionable construct ${@} is simply the var $@. Have a look to
`perldoc perlvar` to learn more about $@. Consider the content of the
first pair of square brackets in Abigail's print-statement:

$#{ @{ ${@} } }
`--
just the var $@
`-------
dereferencing its value (seems to be an arrayref)
`-------------
getting this arrays highest index

I hope these steps will help you to understand that funny code.

regards,
fabian

Leslie Viljoen 02-27-2005 12:56 PM

Re: The meaning of @
 
GreenLeaf wrote:
> Leslie Viljoen wrote:
>
>> Hello!
>>
>> I have been trying to figure out one of Abigail's JAPH
>> signatures (check http://www.cpan.org/misc/japh):
>>
>> Can someone please explain?
>>
>> Les

>
>
> Didn't she answer this same question from you once, a few days back? :o)
>

Sorry I missed it. Thunderbird does not seem to highlight threads I
have posted in.

Fabian's reply was great though anyway.

Les

GreenLeaf 02-28-2005 01:50 AM

Re: The meaning of @
 
Leslie Viljoen wrote:

> Sorry I missed it. Thunderbird does not seem to highlight threads I
> have posted in.


May be OT, but View > Messages > Customize.. :o)

sat

John Bokma 02-28-2005 04:26 AM

Re: The meaning of @
 
GreenLeaf wrote:

> Didn't she


She?

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html


Iain Chalmers 02-28-2005 04:53 AM

Re: The meaning of @
 
In article <coidnfLRX9b3AbzfRVn-rw@is.co.za>,
Leslie Viljoen <leslievNO@SPAMicoc.co.za> wrote:

> This is the center of the expression in a few places: ${@}
> Are we dereferencing the @? What does the @ on its own mean?


Just like ${foo} means the same thing as $foo (search for 'disambiguate'
in perldata), so ${@} is equivalent to $@, which perlvar tells us is the
short name for $EVAL_ERROR

>Presumeably the die puts the error message in the @ in some format.


Almost, die puts the error message into $@.

see:
perldoc perldata
perldoc perlvar

cheers,

big
--
On my tombstone they will carve, "IT NEVER GOT FAST
ENOUGH FOR ME."' - Hunter S Thompson, 1937-2005 RIP

GreenLeaf 02-28-2005 06:02 AM

Re: The meaning of @
 
John Bokma wrote:
> GreenLeaf wrote:
>
> > Didn't she

>
> She?
>


http://groups-beta.google.com/groups...il+%2Bshe+perl

How that information got _registered_ in my mind, I'm not sure. I guess
someone referred to Abigail as (she|her) in some other recent post.

Cheers,
sat

John Bokma 02-28-2005 06:38 AM

Re: The meaning of @
 
GreenLeaf wrote:

> John Bokma wrote:
>> GreenLeaf wrote:
>>
>> > Didn't she

>>
>> She?

>
> http://groups-beta.google.com/groups...il+%2Bshe+perl
>
> How that information got _registered_ in my mind, I'm not sure. I guess
> someone referred to Abigail as (she|her) in some other recent post.


PurlGurl? :-D

I use a nice nick a chat, and because the first part could be a girl's name
people mistake me often for a girl, which the regulars consider a very
funny thing :-D (Ok, I admit, using pinkish colors does add to the
confusing).

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html


Leslie Viljoen 02-28-2005 08:22 AM

Re: The meaning of @
 
GreenLeaf wrote:
> John Bokma wrote:
>
>> GreenLeaf wrote:
>>
>> > Didn't she

>> She?
>>

>
> http://groups-beta.google.com/groups...il+%2Bshe+perl
>
> How that information got _registered_ in my mind, I'm not sure. I guess
> someone referred to Abigail as (she|her) in some other recent post.


Hmmm, I apologise for that assumption. Abigail is an exclusively female
name in South Africa AFAIK. Well, half the world thinks I am female too,
going by my name.


All times are GMT. The time now is 09:47 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.