I have the following code:
Code:
#!/usr/bin/perl5
#Read search for hlds_amd
$search=`ps ux | grep hlds_amd | grep -v grep`;
$user=`echo "\$USER"`;
#Get pid for hlds_amd
if ($search=~ m/(kimball [0-9]{1,})/)
{
$amd_pid=$1;
print "\n$user\n";
$amd_pid=~s/\$user //ge;
print "\n$amd_pid\n\n";
#system("kill $amd_pid");
}
I want to substitue the occurence of the username followed by 3 spaces by nothing (remove it). However, it seems the subsitution is not interpolating my variable $user. I have tried adding the e flag onto the end of the expression but it doesn't help.