Reputation: 6173
I am trying to get "loginuser" value from this line. Please suggest
my $ln = CN=xuser\\,user(loginuser),OU=Site-Omg,OU=Accounts_User,OU
if (/ln: (\S.*\S)\s*$/)
{ print $1; }
Upvotes: 0
Views: 23
Reputation: 11216
This will work
use strict;
use warnings;
my $ln = qq{CN=xuser\\,user(loginuser),OU=Site-Omg,OU=Accounts_User,OU};
print $1 . "\n" if $ln =~ /\(([^)]*)/
Things to note
I have used strict and warnings to show any errors in the script( would have been very useful for your original)
I have used qq{...}
to quote the original string
I have ended the line with ;
I have performed the regex match on $ln instead of $_
using $ln =~ ...
I have written correct regex to get the match.
Upvotes: 3