473,325 Members | 2,480 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,325 software developers and data experts.

scalar variable declaration

89
Hi

I have a set of salaras as $a, $b etc..
Since I am using strict and warnings, how do I declare them. I am not initialising to any value. Is there any way to declare them instead of
my $a;
my $b;
...etc

Thanks.
Jul 23 '08 #1
2 1909
numberwhun
3,509 Expert Mod 2GB
The 'warnings' pragma is very good to use. It allows you to catch a number of syntactical errors before posting your code here in the forums.

On the other hand, the strict pragma is also good as it forces you to create safe constructs. The only way to declare variables with strict on is by preceding them with "my", "out", or "uise", with the most common one being my as you have already done. Once you do that once though, you don't have to do it again.

Regards,

Jeff
Jul 23 '08 #2
KevinADC
4,059 Expert 2GB
Hi

I have a set of salaras as $a, $b etc..
Since I am using strict and warnings, how do I declare them. I am not initialising to any value. Is there any way to declare them instead of
my $a;
my $b;
...etc

Thanks.
If you have a list of variables to declare you can do this:

my ($var, @var, %var, $var2);

That packages them and you can then use them as needed. But don't get into the habit of just declaring all your variables at the beginning of a script, only declare them when and where needed, otherwise they are just global variables and that defeats the purpose of using lexical variables.

I think if you had read the strict pragmas documentation the list declaration is discussed. Try and get used to reading the documentation, it might be confusing sometimes but the more you read it the clearer it becomes.
Jul 23 '08 #3

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

Similar topics

83
by: Alexander Zatvornitskiy | last post by:
Hello All! I'am novice in python, and I find one very bad thing (from my point of view) in language. There is no keyword or syntax to declare variable, like 'var' in Pascal, or special syntax in...
4
by: roger | last post by:
I'm having difficulties invoking a user defined table function, when passing to it a parameter that is the result of another user defined function. My functions are defined like so: drop...
7
by: YGeek | last post by:
Is there any difference between declaring a variable at the top of a method versus in the code of the method? Is there a performance impact for either choice? What about if the method will return...
2
by: Thomas Matthews | last post by:
Hi, I'm getting linking errors when I declare a variable in the global scope, but not inside a function. The declarations are the same (only the names have been changed...). class Book {...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
1
by: G Fernandes | last post by:
Hi, can someone tell me what the following words mean as per C/clc: 1) token 2) token sequence 3) scalar variable 4) vector
3
by: Ken Adeniji | last post by:
Must declare the scalar variable '@FirstName' ContactGridViewWebForm.aspx <aspqlDataSource RunAt="server" ID="SqlDataSourceContact" ...
0
by: roamnet | last post by:
hi i created database file with .mdf extention ,sql server as a source and use grid view to display data there're no problem in data retrieve and display,but i want to edit it or insert new...
14
by: subramanian100in | last post by:
Consider the following program: #include <iostream> using namespace std; int main() { int i;
1
by: Tony M | last post by:
vs 2005 - vb .net - web forms - xp pro Can't figure out why I keep getting the error Must declare the scalar variable "@CheckUser". The error happens on SqlDA.Fill(SqlDS). Just trying to make...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.