Sayed, Irfan (Irfan) wrote:
Jeff Pang wrote:
You're actually executing the `who` command,which just take the `am i`
as its arguments.
The results are the same:
$ who am i
pyh pts/0 Oct 26 18:48 (116.21.60.xx)
$ who
pyh pts/0 Oct 26 18:48 (116.21.60.xx)
This is `whoami` 's output:
$ whoami
pyh
Thanks for replying to this mail.
Now I need to write a regular expression so that I only get username
from the output of this command.
So I have written like this.
my $usr=`who am i`;
What's the point with asking questions here if you don't listen to the
answers?
chomp( my $usr = `whoami` );
$usr=~ m{(.+)\s$};
What did you expect that to do?
You apparently need to go back to the docs before trying to use regular
expressions.
perldoc perlrequick
perldoc perlreref
perldoc perlretut
perldoc perlre
perldoc perlop
(the latter describes the s/// and m// operators)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/