473,915 Members | 5,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GLOBAL Variables with qw()

Icecrack
174 Recognized Expert New Member
Thanks in Advance,

when declaring GLOBAL Variables can we use qw() ?

example:
Expand|Select|Wrap|Line Numbers
  1. my qw($data $id $test $var);
etc.


i will be testing this but if any one knows with in the next 1 hr please post
thanks

Thank You,

Charlie
Oct 3 '08 #1
6 7436
nithinpes
410 Recognized Expert Contributor
'my' is used to declare local variables. To declare multiple variables at once, you may use:
Expand|Select|Wrap|Line Numbers
  1. my ($data,$id,$test,$var); 
  2.  
qw() can be used only on RHS of any assignment statement, as in:
Expand|Select|Wrap|Line Numbers
  1. my @a = qw(ad sat d f g);
  2.  

-Nithin
Oct 3 '08 #2
Icecrack
174 Recognized Expert New Member
'my' is used to declare local variables.
Thank's i know that you may use:

Expand|Select|Wrap|Line Numbers
  1. use var qw($test $perl $var $etc);
Oct 3 '08 #3
NeoPa
32,584 Recognized Expert Moderator MVP
Charlie,

There seems to have been a little misunderstandin g about what the Experts area is for.

Not a problem. I can move this thread for you, but technical questions still go in the relevant technical forum.

The Experts forum is for directing the attention of other experts to a tricky problem thread, or discussing issues related to the experts generally.
Oct 5 '08 #4
KevinADC
4,059 Recognized Expert Specialist
Thanks in Advance,

when declaring GLOBAL Variables can we use qw() ?

example:
Expand|Select|Wrap|Line Numbers
  1. my qw($data $id $test $var);
etc.


i will be testing this but if any one knows with in the next 1 hr please post
thanks

Thank You,

Charlie

If you look up qw in perl operators you will see it also does not interpolate variables. In other words, its the same as using single-quotes, so scalars will not be interpolated when used in a qw list.

Expand|Select|Wrap|Line Numbers
  1. $foo = 'test';
  2. my @list = qw($foo);
  3. print $list[0]; 
prints $foo
Oct 5 '08 #5
KevinADC
4,059 Recognized Expert Specialist
Thank's i know that you may use:

Expand|Select|Wrap|Line Numbers
  1. use var qw($test $perl $var $etc);
Yes that is OK, because it supplies a list to the vars pragma. Note that "vars" is obsolete but still supported.
Oct 5 '08 #6
Icecrack
174 Recognized Expert New Member
Yes that is OK, because it supplies a list to the vars pragma. Note that "vars" is obsolete but still supported.

Thank you all for your input,

Charlie
Oct 8 '08 #7

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

Similar topics

4
24193
by: Andrew V. Romero | last post by:
I have been working on a function which makes it easier for me to pull variables from the URL. So far I have: <script language="JavaScript"> var variablesInUrl; var vArray = new Array(); function loadUrlVariables() { varString = location.search;
17
5656
by: MLH | last post by:
A97 Topic: If there is a way to preserve the values assigned to global variables when an untrapped runtime error occurs? I don't think there is, but I thought I'd ask. During development, I'm constantly running tests on imperfect code. On of the cumbersome jobs encountered is reassigning global vars their values after a close encounter with an untrapped runtime error. Rather than writing a procedure to simply reassign them all with a...
33
3077
by: MLH | last post by:
I've read some posts indicating that having tons of GV's in an Access app is a bad idea. Personally, I love GVs and I use them (possibly abuse them) all the time for everything imaginable - have been for years. If the machine has memory to spare and windows can use it - I'm thinking "Why not?" I was wondering what some of you have to say about that, particularly any severe "gotchas" you've had the unfortunate experience to contend with.
9
8682
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang Su Gatlin, casual mention was made about using static variables as an alternative to using global variables. This caused me to think of the following: '-----Begin module code
5
11842
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global $MYVAR, $a; ?>
4
1760
by: pcaisse | last post by:
I'm having issues sharing global variables with Explorer. This problem probably has a simple answer (as with most newbie questions). The script.pl file: #!/usr/bin/perl -w use strict; use diagnostics; use sigtrap;
1
29420
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have called it polluting the global namespace. This article explores what happens when the global namespace becomes polluted and how to avoid this condition. The opinions expressed in this article are those of the author alone although many have...
8
3833
by: rottmanj | last post by:
. In order to teach my self more. I have started to convert some of my cf scheduled tasks to perl applications. One area where things are kind of fuzzy is setting up global variables that can be called from any module with in an application. So far I have created a farily standard module that will act as my global config. This module will store variables that are populated from the database. So that I will not be forced to re-create/query...
4
1635
Kelicula
by: Kelicula | last post by:
Hello all, I need to create a certain number of variables depending on a result set from a database. I only want to display 20 records per page, and I would like to have those page "markers" at the botton of the page for NEXT, PREVIOUS, and the links to the actual pages eg: 1, 2, 3 etc.. So far what I have is: #!c:/Perl/bin/perl use strict;
112
5528
by: istillshine | last post by:
When I control if I print messages, I usually use a global variable "int silent". When I set "-silent" flag in my command line parameters, I set silent = 1 in my main.c. I have many functions that may print some messages. foo(...) { if (!silent)
0
10039
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9883
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11359
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11069
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5944
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.