The meaning of @

Discussion in 'Perl Misc' started by Leslie Viljoen, Feb 27, 2005.

  1. 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
     
    Leslie Viljoen, Feb 27, 2005
    #1
    1. Advertising

  2. Leslie Viljoen

    GreenLeaf Guest

    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? :eek:)
     
    GreenLeaf, Feb 27, 2005
    #2
    1. Advertising

  3. 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
     
    Fabian Pilkowski, Feb 27, 2005
    #3
  4. 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? :eek:)
    >

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

    Fabian's reply was great though anyway.

    Les
     
    Leslie Viljoen, Feb 27, 2005
    #4
  5. Leslie Viljoen

    GreenLeaf Guest

    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.. :eek:)

    sat
     
    GreenLeaf, Feb 28, 2005
    #5
  6. Leslie Viljoen

    John Bokma Guest

    John Bokma, Feb 28, 2005
    #6
  7. In article <>,
    Leslie Viljoen <> 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
     
    Iain Chalmers, Feb 28, 2005
    #7
  8. Leslie Viljoen

    GreenLeaf Guest

    GreenLeaf, Feb 28, 2005
    #8
  9. Leslie Viljoen

    John Bokma Guest

    GreenLeaf wrote:

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

    >>
    >> She?

    >
    > 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).

    --
    John Small Perl scripts: http://johnbokma.com/perl/
    Perl programmer available: http://castleamber.com/
    Happy Customers: http://castleamber.com/testimonials.html
     
    John Bokma, Feb 28, 2005
    #9
  10. GreenLeaf wrote:
    > John Bokma wrote:
    >
    >> GreenLeaf wrote:
    >>
    >> > Didn't she

    >> She?
    >>

    >
    > 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.


    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.
     
    Leslie Viljoen, Feb 28, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sander Odekerken

    Meaning of output value?

    Sander Odekerken, May 18, 2004, in forum: VHDL
    Replies:
    2
    Views:
    2,505
    John_H
    May 18, 2004
  2. Parthav
    Replies:
    4
    Views:
    1,920
    Mike Treseler
    Jan 13, 2006
  3. Frank

    Meaning of <%#

    Frank, Dec 30, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    580
  4. .NET Follower

    Meaning Of Timeout in FormsAuthentication???

    .NET Follower, Feb 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    369
    .NET Follower
    Feb 6, 2004
  5. Replies:
    4
    Views:
    774
Loading...

Share This Page