Simple syntax question

Discussion in 'Perl Misc' started by Trimbitas Sorin, Feb 4, 2004.

  1. Hello
    I have a simple syntax question :
    What does the following line mean:
    1: %checkType; ?? I know that @test="" is an array and $test="" is a
    simple variable.
    Thank you
    With best regards
    Trimbitas Sorin
    Trimbitas Sorin, Feb 4, 2004
    #1
    1. Advertising

  2. Trimbitas Sorin

    Mike Ellwood Guest

    On Wed, 4 Feb 2004, Trimbitas Sorin wrote:

    > Hello
    > I have a simple syntax question :
    > What does the following line mean:
    > 1: %checkType; ?? I know that @test="" is an array and $test="" is a
    > simple variable.
    > Thank you
    > With best regards
    > Trimbitas Sorin


    Learn to fish.

    The answer can be found, for example, somewhere here:

    http://learn.perl.org/library/beginning_perl/

    (look for hashes), or e.g. "Learning Perl" published by O'Reilly.
    (and cheap at twice the price :) )

    Regards,

    --
    Mike Ellwood, Feb 4, 2004
    #2
    1. Advertising

  3. Trimbitas Sorin

    Web Surfer Guest

    In article <>, lacroix-
    says...
    > Hello
    > I have a simple syntax question :
    > What does the following line mean:
    > 1: %checkType; ?? I know that @test="" is an array and $test="" is a
    > simple variable.
    > Thank you
    > With best regards
    > Trimbitas Sorin
    >


    %checktype is a "hash"

    # unlike a "normal" array whose index value needs to be an integer
    value, the "index" for a hash can be just about any kind of scalar
    value.

    %colors = ( "apple" => "red" , "orange" => "orange" ,
    "lemon" => "yellow" );

    print "The color of an apple is ",$colors{"apple"},"\n";

    Consult the "perldoc" command or your Perl reference manual for further
    details on hashes.
    Web Surfer, Feb 4, 2004
    #3
  4. Trimbitas Sorin

    Ben Morrow Guest

    Web Surfer <> wrote:
    > %checktype is a "hash"
    >
    > # unlike a "normal" array whose index value needs to be an integer
    > value, the "index" for a hash can be just about any kind of scalar
    > value.


    No. The key ('index') for a hash is a string.

    Ben

    --
    For the last month, a large number of PSNs in the Arpa[Inter-]net have been
    reporting symptoms of congestion ... These reports have been accompanied by an
    increasing number of user complaints ... As of June,... the Arpanet contained
    47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] *
    Ben Morrow, Feb 4, 2004
    #4
  5. In article <bvrg33$rn$>,
    Ben Morrow <> wrote:

    :Web Surfer <> wrote:
    :> # unlike a "normal" array whose index value needs to be an integer
    :> value, the "index" for a hash can be just about any kind of scalar
    :> value.

    :No. The key ('index') for a hash is a string.

    True, but other kinds of scalars will be stringified and -that-
    used as the key.

    stringification can have some surprising results. For example,
    I discovered just a couple of days ago that every time you
    stringify a Thread::Queue then you get a different value, even
    if the queue has not changed in the meantime.
    --
    So you found your solution
    What will be your last contribution?
    -- Supertramp (Fool's Overture)
    Walter Roberson, Feb 4, 2004
    #5
  6. Trimbitas Sorin

    Tore Aursand Guest

    On Wed, 04 Feb 2004 08:46:27 -0800, Trimbitas Sorin wrote:
    > I have a simple syntax question :
    > What does the following line mean:
    > 1: %checkType; ?? I know that @test="" is an array and $test="" is a
    > simple variable.


    perldoc perldata


    --
    Tore Aursand <>
    "Life is pleasant. Death is peaceful. It's the transition that's
    troublesome." -- Isaac Asimov
    Tore Aursand, Feb 4, 2004
    #6
  7. Trimbitas Sorin

    Paul Lalli Guest

    On Wed, 4 Feb 2004, Walter Roberson wrote:

    > In article <bvrg33$rn$>,
    > Ben Morrow <> wrote:
    >
    > :Web Surfer <> wrote:
    > :> # unlike a "normal" array whose index value needs to be an integer
    > :> value, the "index" for a hash can be just about any kind of scalar
    > :> value.
    >
    > :No. The key ('index') for a hash is a string.
    >
    > True, but other kinds of scalars will be stringified and -that-
    > used as the key.


    Yes, just as any non-integers used as the index to an array will be
    "integer-fied" and -that- used as the index.

    Paul Lalli
    Paul Lalli, Feb 4, 2004
    #7
  8. Trimbitas Sorin <> wrote:

    > What does the following line mean:
    > 1: %checkType; ?? I know that @test="" is an array and $test="" is a



    I don't know what the "1:" means.

    I don't know what the "??" or the part of the line that follows it means.

    %checkType;

    Is the name of a hash data type, but that statement does not "do"
    anything, it is a useless statement.

    perldoc perldata


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Feb 4, 2004
    #8
    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. Trimbitas Sorin

    Simple syntax question(MULTIPOST)

    Trimbitas Sorin, Feb 4, 2004, in forum: Perl
    Replies:
    2
    Views:
    420
    Joe Smith
    Feb 5, 2004
  2. Greg Smith

    A simple syntax question

    Greg Smith, Jan 29, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    365
    Steven Cheng[MSFT]
    Feb 3, 2004
  3. gabriele renzi
    Replies:
    2
    Views:
    200
    gabriele renzi
    Dec 31, 2005
  4. Ken Bloom
    Replies:
    3
    Views:
    203
  5. Good Night Moon
    Replies:
    9
    Views:
    275
    Rick DeNatale
    Jul 25, 2007
Loading...

Share This Page