On 01/09/11 4:42 PM, Tom Fischer wrote:
> 
>    Can anyone help help me with the syntax to remove spaces from the
> username field? I copied the parserequest from radius.pm to custom.pm. I
> changed:
> 
>     my $user_name =$radius_request->{'User-Name'};
> 
>    to
> 
>     my $user_name =$radius_request->{'Stripped-User-Name'};
> 
>    to fix a backslash issue. Now I'm trying to drop spaces out of the
> names. I tried:
> 
>     my $user_name ={$radius_request->{'Stripped-User-Name'}=~ s/\s//g};
> 
>    but it comes back as HASH(0x2a5f….).
>    I apologize for my lack of Perl skills.  :-<

The s/// operator is performing his changes in-place. You'll be better with:

my $user_name = $radius_request->{'Stripped-User-Name'};
$user_name =~ s/\s//g;

Since this is perl there is more than one way to do it.

The reason why you were getting an HASH(...) is that the { } around your
expression turned the content into an hash reference. When this hashref
was forced into string context, it stringyfies into the HASH(...) thing.

{ } perform both block separation as in if (...) { ... } but also is a
syntactic sugar to create anonymous hash references. All depending on
context.

If s/\s//g wasn't in-place (there's an operator to do it IIRC), you
would have been right by using parenthesis instead of curly brackets.

I like teaching ;)

Cheers!
-- 
Olivier Bilodeau
[email protected]  ::  +1.514.447.4918 *115  ::  www.inverse.ca
Inverse inc. :: Leaders behind SOGo (www.sogo.nu) and PacketFence
(www.packetfence.org)

------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better 
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Packetfence-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/packetfence-users

Reply via email to