xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

Why the stuff printed as below is different?

root@xyf-laptop:~# perl -e ' print getpwuid($<);' root$6$J0bTOS1H$lnxARf6GOL5rPmGIuYR4IkFBbANmrTeSaIj8BrCehOkftUB2xjPbxq +qPLJlzd2C6p4OGCvyIZ6kzhQZ1vRO5d000root/root/bin/bashroot@xyf-laptop:~ +# root@xyf-laptop:~# root@xyf-laptop:~# perl -e ' $a = getpwuid($<); print $a;' rootroot@xyf-laptop:~#




I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Replies are listed 'Best First'.
Re: will assigning variable change the inner value ?
by almut (Canon) on Apr 24, 2010 at 11:07 UTC

    getpwuid() returns different results depending on whether it's called in list context (as with print), or in scalar context, i.e. $a = ...   Try

    $ perl -e '@a = getpwuid($<); print @a;'
      Thanks for your reply!




      I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

Re: will assigning variable change the inner value ?
by Anonymous Monk on Apr 24, 2010 at 11:06 UTC
    scalar versus list context
Re: will assigning variable change the inner value ?
by MidLifeXis (Monsignor) on Apr 26, 2010 at 13:20 UTC

    If you just posted your hashed root password, you may will want to change it.

    --MidLifeXis