Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Simple syntax question

Reply
Thread Tools

Simple syntax question

 
 
Trimbitas Sorin
Guest
Posts: n/a
 
      02-04-2004
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
 
Reply With Quote
 
 
 
 
Mike Ellwood
Guest
Posts: n/a
 
      02-04-2004
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,

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Web Surfer
Guest
Posts: n/a
 
      02-04-2004


In article <(E-Mail Removed) >, lacroix-
(E-Mail Removed) 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.
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      02-04-2004

Web Surfer <(E-Mail Removed)> 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] * (E-Mail Removed)
 
Reply With Quote
 
Walter Roberson
Guest
Posts: n/a
 
      02-04-2004
In article <bvrg33$rn$(E-Mail Removed)>,
Ben Morrow <(E-Mail Removed)> wrote:

:Web Surfer <(E-Mail Removed)> 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)
 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      02-04-2004
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 <(E-Mail Removed)>
"Life is pleasant. Death is peaceful. It's the transition that's
troublesome." -- Isaac Asimov
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      02-04-2004
On Wed, 4 Feb 2004, Walter Roberson wrote:

> In article <bvrg33$rn$(E-Mail Removed)>,
> Ben Morrow <(E-Mail Removed)> wrote:
>
> :Web Surfer <(E-Mail Removed)> 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
 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      02-04-2004
Trimbitas Sorin <(E-Mail Removed)> 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
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax bug, in 1.8.5? return not (some expr) <-- syntax error vsreturn (not (some expr)) <-- fine Good Night Moon Ruby 9 07-25-2007 04:51 PM
[ANN] SqlStatement 1.0.0 - hide the syntax of SQL behind familiarruby syntax Ken Bloom Ruby 3 10-09-2006 06:46 PM
Syntax highligth with textile: Syntax+RedCloth ? gabriele renzi Ruby 2 12-31-2005 02:44 AM
Simple syntax question(MULTIPOST) Trimbitas Sorin Perl 2 02-05-2004 09:52 PM
A simple syntax question Greg Smith ASP .Net 5 02-03-2004 02:35 PM



Advertisments