Where can I find information about Perl's special variables?
Asked Answered
G

2

6

Perl has quite a few special variables such as @F, $!, %! ... etc. Where are all Perl's special variables documented?

Gargantuan answered 5/4, 2010 at 13:44 Comment(5)
There are already at least three questions about Perl's special variables. The answer to each and every one is the same, see perldoc perlvar. I am posting this question so every question of the form What does special variable $@%!!~ do in Perl? can be referred back to this. Of course, those other questions should NOT be deleted - just closed.Mccarter
the trouble with the non-alphanumeric soup is that it's pretty much non-googleable :( ... and by the time someone is aware of the fact that they need to ask/search for "special variables" or that such a generalization exists, they already wouldn't need to ask the Q. So I don't see any way to actually prevent such quetions for perpetuity, BUT this post should help greatly with answering them!Erbium
@Erbium The point is not to prevent them from being asked. In fact, having a question for each variable would be great for indexing. However, there is only one answer to all those questions and therefore they should be closed (NOT deleted) with a pointer to this question.Mccarter
I don't see how we can help people who aren't aware of the standard perldoc documentation. I would never hire anyone who didn't know that perldoc perl gave the index of all entries.Confab
The organization of the Perl documentation is a mess. There's plenty we can do to help people use it better. Imagine this question as "Where could I find information on creating Perl variables?" Only about a quarter of the people I ask know the answer, and this includes people who know Perl quite well.Bedcover
C
4

All special variables used by Perl are documented in perldoc perlvar. You can view this document on your computer by running

perldoc perlvar

The documentation for a specific special variable can also be accessed at the command line using perldoc -v:

perldoc -v @F

You may need to escape/quote some variables to avoid interpolation by your shell:

perldoc -v '$!'

or

perldoc -v "$!"

if you are using cmd.exe.

For more information:

perldoc -h
perldoc perldoc
Collaborationist answered 5/4, 2010 at 13:44 Comment(2)
Oooh, didn't know about that. Sweet!Ophiuchus
the powers that be decided to lose that feature in the 'perldoc rewrite' in perl 5.9, now it is, 'be verbose'Heliograph
B
8

All special variables used by Perl are documented in perldoc perlvar. You can access the version of this documentation that came with your perl by entering perldoc perlvar on the command line.

Boyd answered 5/4, 2010 at 13:44 Comment(1)
@Boyd Apparently we posted essentially the same answer at the same time. So I deleted mine and put the extra info in it in your post so there aren't two substantially identical answers.Mccarter
C
4

All special variables used by Perl are documented in perldoc perlvar. You can view this document on your computer by running

perldoc perlvar

The documentation for a specific special variable can also be accessed at the command line using perldoc -v:

perldoc -v @F

You may need to escape/quote some variables to avoid interpolation by your shell:

perldoc -v '$!'

or

perldoc -v "$!"

if you are using cmd.exe.

For more information:

perldoc -h
perldoc perldoc
Collaborationist answered 5/4, 2010 at 13:44 Comment(2)
Oooh, didn't know about that. Sweet!Ophiuchus
the powers that be decided to lose that feature in the 'perldoc rewrite' in perl 5.9, now it is, 'be verbose'Heliograph

© 2022 - 2024 — McMap. All rights reserved.