The meaning of @

L

Leslie Viljoen

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
 
F

Fabian Pilkowski

Leslie said:
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
 
L

Leslie Viljoen

GreenLeaf said:
Didn't she answer this same question from you once, a few days back? :eek:)
Sorry I missed it. Thunderbird does not seem to highlight threads I
have posted in.

Fabian's reply was great though anyway.

Les
 
I

Iain Chalmers

Leslie Viljoen said:
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
 
J

John Bokma

GreenLeaf said:
http://groups-beta.google.com/groups?q=abigail++she+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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top