Yes, I'm using your code. like i said it works, but $2 only has the role name, not the group name. ideally I'd like $2 to have the group name and $3 to have the role name.
I updated the original post. The string gets messed up when you post it with < code > tags.
my $string ="Group: Group Name▼▼Role: Role Name"
Thanks!
| [reply] |
#!perl
use strict;
use HTML::Entities;
use Data::Dump 'pp';
my $string = "Group: Group Name▼▼Role: Role Name";
$string = decode_entities($string);
my $href={};
while ( $string =~ /(Group|Role)\:\s+([\x00-\x7f]*)/g ){
$href->{$1} = $2;
};
pp $href;
print "Role = $href->{'Role'}\n";
print "Group= $href->{'Group'}\n";
poj | [reply] [d/l] |
Getting closer... Thank you! Sorry if I'm not clear enough, there's a lot of strings I'm matching against, but what I want remains the same. I want the group and role names in the hash. For instance, I used a string like this:
$string = "Role: Role Name▼▼Profile: Unnecessary_Extra_Stuff";
but it returned:
This is the Role Name:Role Name▼▼Profile Name: Unnecessary_Extra_Stuff
FYI, here's my code snippet:
while ( ${$ref}{$k}{'DIRTYDATA'} =~ /(Group|Role)\:\s+([\x00-\x7f]*)/g
+ ){
${$ref}{$k}{$1} = $2;
}
print "\n\nThis is the Group Name: " . ${$ref}{$k}{Group};
print "\nThis is the Role Name: " . ${$ref}{$k}{Role};
I only want it to return Group or Role names, not Profile names and no extended ascii characters.
I did mention an array before, but it's storing fine in my HoH which I'm getting out of a fetchall hashref from DBI, so storage really isn't the problem, the problem is only matching role group names in these dirty little strings.
Thanks.
| [reply] [d/l] |