Simple syntax question

  • Thread starter Trimbitas Sorin
  • Start date
T

Trimbitas Sorin

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
 
M

Mike Ellwood

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,
 
W

Web Surfer

lacroix- said:
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.
 
B

Ben Morrow

Web Surfer said:
%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
 
W

Walter Roberson

:> # 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.
 
T

Tore Aursand

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
 
P

Paul Lalli

:> # 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
 
T

Tad McClellan

Trimbitas Sorin said:
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
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top