$ who --help
Usage: who [OPTION]... [ FILE | ARG1 ARG2 ]
...
-m only hostname and user associated with stdin
...
If ARG1 ARG2 given, -m presumed: `am i' or `mom likes' are usual.
`who am i` is the same as writing `who -m`
------------
$ whoami --help
..
Same as id -un.
------------
Why not just use `whoami`? It gives you exactly what you want.
On 10/26/07, Sayed, Irfan (Irfan) <[EMAIL PROTECTED]> wrote:
> my $usr=`who am i`;
> $usr=~ m{(.+)\s$};
> print "$usr\n";
The 'm' means match. It is searching the string (eg "irfan pts/5
Oct 26 09:59 (127.0.0.1:S.1)") for "some text" followed by
whitespace then an endline. The "some text" gets stored in $1.
You probably want:
$usr=~ m/^([^\s]+)\s/;
$usr = $1;
This will search for: begin line, (some text that does not have
whitespace in it), whitespace. The bracketed text gets stored in $1.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/