Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > FAQ 7.2 What are all these $@%&* punctuation signs, and how do I know when to use them?

Reply
Thread Tools

FAQ 7.2 What are all these $@%&* punctuation signs, and how do I know when to use them?

 
 
PerlFAQ Server
Guest
Posts: n/a
 
      02-09-2011
This is an excerpt from the latest version perlfaq7.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .

--------------------------------------------------------------------

7.2: What are all these $@%&* punctuation signs, and how do I know when to use them?

They are type specifiers, as detailed in perldata:

$ for scalar values (number, string or reference)
@ for arrays
% for hashes (associative arrays)
& for subroutines (aka functions, procedures, methods)
* for all types of that symbol name. In version 4 you used them like
pointers, but in modern perls you can just use references.

There are couple of other symbols that you're likely to encounter that
aren't really type specifiers:

<> are used for inputting a record from a filehandle.
\ takes a reference to something.

Note that <FILE> is *neither* the type specifier for files nor the name
of the handle. It is the "<>" operator applied to the handle FILE. It
reads one line (well, record--see "$/" in perlvar) from the handle FILE
in scalar context, or *all* lines in list context. When performing open,
close, or any other operation besides "<>" on files, or even when
talking about the handle, do *not* use the brackets. These are correct:
"eof(FH)", "seek(FH, 0, 2)" and "copying from STDIN to FILE".



--------------------------------------------------------------------

The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.

If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How get all digits, letters and punctuation characters in perl? Peng Yu Perl Misc 2 12-04-2012 09:44 AM
FAQ 7.2 What are all these $@%&* punctuation signs, and how do I know when to use them? PerlFAQ Server Perl Misc 0 02-19-2011 11:00 AM
help i dont know how to use these news proup avel zamora Computer Support 4 11-27-2006 10:21 AM
I know, I know, I don't know Andries Perl Misc 3 04-23-2004 02:17 AM



Advertisments