473,396 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Special Variables

173 100+
Hi,

i need serious help with special variables, ie $_ $/ etc etc

I just cant seem to understand these...

can someone please explain these variables to me in the simplest form? POSSIBLY PROVIDING AN EXAMPLE....

I've read tonnes of info on them but can't seem to get my head around it..

thanks in advance
Jul 8 '08 #1
2 1062
KevinADC
4,059 Expert 2GB
Don't get confused. They are really like any other scalar in perl, for example:

Expand|Select|Wrap|Line Numbers
  1. $foo = 'foo';
The one that is the most different is $_ which is simply the default scalar that perl uses for many functions if you do not tell perl which scalar to use, for example:

Expand|Select|Wrap|Line Numbers
  1. chomp;
the above performs chomp on $_.

Expand|Select|Wrap|Line Numbers
  1. chomp $foo;
the above performs chomp on $foo.

(See $_ on the page linked to below.)

Other variables like $/ are just predefined variables that perl uses for many internal operations. Each time you run perl, perl gives them a value (predefined).

They are all discussed on this page and many have examples: http://perldoc.perl.org/perlvar.html

They are all global in scope (last time I checked). Meaning you have to use the local() function if you want to create a temporary definition for one of them in a block of code. See the local() function documentation.
Jul 8 '08 #2
Beany
173 100+
cool,

will have a look at the link..
thanks
Jul 9 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Mosher | last post by:
Hi all, I have an issue with php and/or mysql. I have a php form that writes "items" to a mysql database, including a description of the item. On the mysql server, "magic_quotes_gpc" is ON. I...
14
by: tertius | last post by:
Is there a better way to append certain chars in a string with a backslash that the example below? chr = "#$%^&_{}" # special chars to look out for str = "123 45^ & 00 0_" # string to...
2
by: Jim Schueler | last post by:
Here is some sample code that uses inherited class methods: sub parseHTML::docomment { my $comment = shift ; print $comment, "\n" ; } sub parseASP::AUTOLOAD { use vars qw( $AUTOLOAD ) ;
1
by: Vannela | last post by:
In my unmamaged code varaibles declaration can use special characters like - Dash _ Underscore (C# allows except this) $ Dollar sign # Number sign % Percent sign but C# will...
3
by: ATH0 | last post by:
How to search for special character { } and how to count them.. I got field called text ( undefined length ) and in this field you must define "{" as start and "}" as end of some text line. If...
4
by: dutch disCo | last post by:
Hi, I'm trying to use GET method to pass variables through my script files. Unfortunately, when a special char (&, ?, +) is being posted the variable gets trimmed in a very strange way. I'm...
8
by: Lyn | last post by:
I am trying to get my head around the concept of default, special or empty values that appear in Access VBA, depending on data type. The Access Help is not much (help), and the manual that I have...
11
by: T O | last post by:
Hi all, I am very new to C programming and have come across problem. My programme has opened and created a text document on the hard drive. The document name is stored in a string called...
9
by: TP | last post by:
Hi everybody, I am new to Python, I try to understand how Python treats special characters. For example, if I execute the following line in a shell console, I obtain a colored string: $...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.