difference between $ and @

Discussion in 'Perl Misc' started by vimal, Mar 14, 2008.

  1. vimal

    vimal Guest

    hi monks,

    i am new to perl. i just want to know the difference between @ and $
    prefixes for variables.

    when should i use $ and @ as prefix.
    an example may be a little useful :)


    regards,

    vimal
    vimal, Mar 14, 2008
    #1
    1. Advertising

  2. Peter Makholm, Mar 14, 2008
    #2
    1. Advertising

  3. vimal

    vimal Guest

    vimal, Mar 14, 2008
    #3
  4. vimal <> wrote:
    > On Mar 14, 12:12 pm, Peter Makholm <> wrote:
    >> vimal <> writes:
    >> > i am new to perl. i just want to know the difference between @ and $
    >> > prefixes for variables.

    >>
    >> http://search.cpan.org/~rgarcia/perl-5.10.0/pod/perldata.pod
    >>
    >> //Makholm

    >
    > Thats a cool one and now i got that.



    If you had perl installed, then you already had that, as perl ships
    and installs that document, along with a boatload of other docs.


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Mar 14, 2008
    #4
  5. vimal <> wrote:
    >hi monks,


    What does religious asceticism have to do with Perl?

    >i am new to perl. i just want to know the difference between @ and $
    >prefixes for variables.


    See the first page or so of perldoc perldata. It is a rather terse but
    well-written introduction into that subject matter.

    >when should i use $ and @ as prefix.


    Use $ whenever you are talking about a single value aka scalar. Use @ when
    you are talking about a collection of values which is indexed by consecutive
    natural numbers.

    >an example may be a little useful :)


    perldoc perldata has numerous examples.

    jue
    Jürgen Exner, Mar 14, 2008
    #5
    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. jakk
    Replies:
    4
    Views:
    12,116
  2. Santa
    Replies:
    1
    Views:
    1,072
    Mark A. Odell
    Jul 17, 2003
  3. arnuld
    Replies:
    33
    Views:
    1,176
  4. PerlFAQ Server
    Replies:
    0
    Views:
    354
    PerlFAQ Server
    Jan 6, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    258
    PerlFAQ Server
    Apr 15, 2011
Loading...

Share This Page