Rajnikant wrote:
Hey Richard,
I think $< returns user id. Correct me if I'm wrong ;-).
yes, you are correct.
I was reading the perldoc .. on this and I was bit confused at first, on
$uid = getpwnam <http://perldoc.perl.org/functions/getpwnam.html>($name);
$name = getpwuid <http://perldoc.perl.org/functions/getpwuid.html>($num);
$name = getpwent <http://perldoc.perl.org/functions/getpwent.html>();
$gid = getgrnam <http://perldoc.perl.org/functions/getgrnam.html>($name);
$name = getgrgid <http://perldoc.perl.org/functions/getgrgid.html>($num);
$name = getgrent <http://perldoc.perl.org/functions/getgrent.html>();
so I tried this..
#!/usr/bin/perl
use warnings;
use strict;
my $usr = getpwnam(getpwuid($<));
print "\$usr is $usr\n";
[EMAIL PROTECTED] tmp]$ ./!$
././././././././test_getpw.pl
$usr is 500
[EMAIL PROTECTED] tmp]$
scalar command did not work for me.(for whatever reason).
so this way it works but then, wait a min I thought, this is stupid. so
why not just do...
#!/usr/bin/perl
use warnings;
use strict;
#my $usr = getpwnam(getpwuid($<));
my $usr = $<;
print "\$usr is $usr\n";
[EMAIL PROTECTED] tmp]$ ./!$
././././././././././test_getpw.pl
$usr is 500
[EMAIL PROTECTED] tmp]$
so just wondering is there some kind of security implication of using $<
directly opposed to getting it through getpw* ?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/