help required reg eval qq

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • user1357
    New Member
    • Mar 2008
    • 4

    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.

    Code:
    $hex1='\xd1';
    
    $conv = eval qq "$hex1";
    
    print "CONV IS $conv \n";
    o/p is as follows

    CONV IS SCALAR(0x183f1c 4)

    Code:
    $hex1='\xd1';
    
    $conv = eval qq ("$hex1");
    
    print "CONV IS $conv \n";
    o/p is as follows
    CONV IS ╤
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    Originally posted by user1357
    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.

    Code:
    $hex1='\xd1';
    
    $conv = eval qq "$hex1";
    
    print "CONV IS $conv \n";
    o/p is as follows

    CONV IS SCALAR(0x183f1c 4)

    Code:
    $hex1='\xd1';
    
    $conv = eval qq ("$hex1");
    
    print "CONV IS $conv \n";
    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:

    Code:
    $hex1='\xd1';
    $conv = eval $hex1;
    print "CONV IS $conv \n";
    In the second example the () are the delimiter for the qq operator, so the code is the same as:

    Code:
    $hex1='\xd1';
    $conv = eval "\"$hex1\"";
    print "CONV IS $conv \n";

    Comment

    Working...