For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2004 > REAL_USER_ID









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author REAL_USER_ID
Prasanna Kothari

2004-07-23, 8:56 am

Hi,
What's difference between these 2 statements:
$uid = *REAL_USER_ID --> Getting a wrong value
and
$uid = $REAL_USER_ID --> Getting the correct value.

AFAIK the first statement assigns all type glob values to $uid.
Am I right? Am I missing something here?



Bob Showalter

2004-07-23, 8:56 am

Prasanna Kothari wrote:
> Hi,
> What's difference between these 2 statements:
> $uid = *REAL_USER_ID --> Getting a wrong value
> and
> $uid = $REAL_USER_ID --> Getting the correct value.
>
> AFAIK the first statement assigns all type glob values to $uid.


The first assigns a typeglob to $uid. This can let you access all the symbol
table entries named REAL_USER_ID through $uid. It's kind of like a
reference, so you have to dereference it to get to the scalar value of
$REAL_USER_ID:

$uid = *REAL_USER_ID;
print "User ID is ", $$uid;

If you do it the following way, you're making uid an alias for REAL_USER_ID:

*uid = *REAL_USER_ID;
print "User ID is ", $uid;

In fact, this is what the English module is doing.

> Am I right? Am I missing something here?


Why are you messing with the typeglob? What are you trying to accomplish?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com