467,179 Members | 1,231 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,179 developers. It's quick & easy.

GLOBAL Variables with qw()

Icecrack
Expert 100+
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
  • viewed: 7102
Share:
6 Replies
nithinpes
Expert 256MB
'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
Expert 100+
'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
Expert Mod 16PB
Charlie,

There seems to have been a little misunderstanding 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
Expert 2GB
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
Expert 2GB
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
Expert 100+
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

Post your reply

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

Similar topics

4 posts views Thread by Andrew V. Romero | last post: by
9 posts views Thread by CDMAPoster@FortuneJames.com | last post: by
5 posts views Thread by Sandman | last post: by
8 posts views Thread by rottmanj | last post: by
112 posts views Thread by istillshine@gmail.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.