Wednesday, 16 October 2019

what will be the value if we directly print the reference in perl?

Method 1:

$ref=\"DAM-DAMA-DAMAAR";
print $ref;                     #SCALAR(0x111ac40)


Method 2:

$varr=6;
$ref="varr";
print "$ref";                 #varr


Method 3:

@b=(4,5,6);
$ref="b";
print "$ref";                 #b


Method 4:

%I=(c,d);
$ref="I";
print "$ref";            #I


Method 5:

sub FName
{

    print "DAM-DAMA-DAMAAR\n";

}

$ref="FName";
print $ref;                        #FName


Method 6:

$varr=7;
$ref=\$varr;
print $ref;                       #SCALAR(0x14bcc28)


Method 7:

@b=(4,5,6);
$ref=\@b;
print "$ref";             #ARRAY(0x23a1c28)


Method 8:

%f=(b=>c);
$ref=\%f;
print "$ref\n";      #HASH(0x22e3c28)


Method 9:

sub FName
{

    print "DAM-DAMA-DAMAAR\n";

}

$ref=\&FName;

print $ref;                         #CODE(0xa70c28)


Method 10:

sub FName
{

    my $b=shift;
    print $b;                   #GLOB(0x1fc6bf8)

}

open(FIL1,">b.txt");
name(\*FIL1);       


Method 11:

$b="DAM-DAMA-DAMAAR";
$ref=\substr($b,0,1);
print $ref;              #LVALUE(0x112af30)


Method 12:

$ref=[4,5,6];
print "$ref";         #ARRAY(0x17f2f30)


Method 13:

$ref=[qw/4 5 6/];
print "$ref";         #ARRAY(0xd3af30)


Method 14:

$ref=[qq/4 5 6/];
print "$ref";         #ARRAY(0x27a6f30)


Method 15:

$ref={c=>D,f=>U};
print $ref;            #HASH(0x1408f30)


Method 16:

$ref= sub {print "DAM-DAMA-DAMAAR\n"};
print $ref;                      #CODE(0x25b0c40)


Method 17:

$varr=55;
$ref=*varr{SCALAR};
print $ref;               #SCALAR(0x23f6c28)



Method 19:

sub FName
{
    print  "DAM-DAMA-DAMAAR\n";
}

$ref=*FName{CODE};
print $ref;                          #CODE(0x2699c28)


Method 20:

@a[0]=[1,2,9,4,5];
@a[1]=[1,2,9,4,5];
@a[2]=[1,2,9,4,5];
@a[3]=[1,2,9,4,5];


print @a;             
#ARRAY(0x20e0f30)ARRAY(0x20fe640)
ARRAY(0x210b370)ARRAY(0x210b418)


Method 21:

$h{1} = { c => "jhjhjh", m => "jhkjkjh", 
          r => "jgjhgjh", }; 
$h{2} = { a => "nbvbnv", b => "fdfdf",
          d => "nbmnbm", }; 
$h{3} = { k => "jhgjh", g => "jhhbm",
          h => "jhjh", }; 



print  %h;

   #3HASH(0xfdd640)1HASH(0xfbff30)2HASH(0xfc0128)

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home