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.

help required reg eval qq

Hi All,

Could you please explain the difference b/w the below codes?

when qq is used with eval and without () the o/p is different.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $hex1='\xd1';
  3.  
  4. $conv = eval qq "$hex1";
  5.  
  6. print "CONV IS $conv \n";
  7.  
  8.  
o/p is as follows

CONV IS SCALAR(0x183f1c4)

Expand|Select|Wrap|Line Numbers
  1.  
  2. $hex1='\xd1';
  3.  
  4. $conv = eval qq ("$hex1");
  5.  
  6. print "CONV IS $conv \n";
  7.  
  8.  
o/p is as follows
CONV IS ╤
Jun 19 '08 #1
  • viewed: 1826
Share:
1 Reply
KevinADC
Expert 2GB
Hi All,

Could you please explain the difference b/w the below codes?

when qq is used with eval and without () the o/p is different.

Expand|Select|Wrap|Line Numbers
  1.  
  2. $hex1='\xd1';
  3.  
  4. $conv = eval qq "$hex1";
  5.  
  6. print "CONV IS $conv \n";
  7.  
  8.  
o/p is as follows

CONV IS SCALAR(0x183f1c4)

Expand|Select|Wrap|Line Numbers
  1.  
  2. $hex1='\xd1';
  3.  
  4. $conv = eval qq ("$hex1");
  5.  
  6. print "CONV IS $conv \n";
  7.  
  8.  
o/p is as follows
CONV IS ╤
In the first example, the double-quotes are the delimiter for the qq operator, so the code is the same as:

Expand|Select|Wrap|Line Numbers
  1. $hex1='\xd1';
  2. $conv = eval $hex1;
  3. print "CONV IS $conv \n";
  4.  
In the second example the () are the delimiter for the qq operator, so the code is the same as:

Expand|Select|Wrap|Line Numbers
  1. $hex1='\xd1';
  2. $conv = eval "\"$hex1\"";
  3. print "CONV IS $conv \n";
  4.  
Jun 19 '08 #2

Post your reply

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

Similar topics

2 posts views Thread by Phil Powell | last post: by
5 posts views Thread by aesahab@gmail.com | last post: by
1 post views Thread by stuart dent via .NET 247 | last post: by
1 post views Thread by Dody Suria Wijaya | last post: by
11 posts views Thread by Naeem | last post: by
3 posts views Thread by madhumita.iyengar@gmail.com | last post: by
7 posts views Thread by Ciaran | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.