By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,903 Members | 1,104 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,903 IT Pros & Developers. It's quick & easy.

help required reg eval qq

P: 4
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
Share this Question
Share on Google+
1 Reply


KevinADC
Expert 2.5K+
P: 4,059
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.