eol has asked for the wisdom of the Perl Monks concerning the following question:
use 5.6.0; use warnings; use strict; use utf8; my %user; while (<>){ /^ (\p{L}*)\p{Cc} # Action to be performed (\p{L}*)\p{Cc} # Need mailbox created? (\p{L}*)\p{Cc} # Last Name (\p{L}*)\p{Cc} # First Name ([\p{L}&&\p{N}]*)\p{Cc} # Rank ([\p{L}&&\p{N}\p{P}&&\p{Zs}]*)\p{Cc} # Unit (\(?31\p{N}\)?[-. ]?\p{N}{3}[-. ]?\p{N}{4}) #DSN Number $/x; %user = ( action => lc($1), mail => lc($2), lname => ucfirst(lc($3)), fname => ucfirst(lc($4)), rank => uc($5), unit => $6, phone => $7, user => ucfirst(lc($3)).uc(substr($4,0,1)) ); } foreach my $key (keys %user) { print "$key $user{$key}\n"; } __END__
-user => ucfirst(lc($3)).uc(substr($4,0,1)) +user => "@{[ ucfirst (lc $3) . uc (substr $4, 0, 1) ]}"
use 5.6.0; use warnings; use strict; use utf8; my %user; while (<>){ /^ (\p{L}*)\p{Cc} # Action to be performed (\p{L}*)\p{Cc} # Need mailbox created? (\p{L}*)\p{Cc} # Last Name (\p{L}*)\p{Cc} # First Name ([\p{L}&&\p{N}]*)\p{Cc} # Rank ([\p{L}&&\p{N}\p{P}&&\p{Zs}]*)\p{Cc} # Unit (\(?31\p{N}\)?[-. ]?\p{N}{3}[-. ]?\p{N}{4}) #DSN Number $/x; print "1=$1 2=$2 3=$3 4=$4 5=$5 6=$6 7=$7\n"; my $user = $3; print "user=$user\n"; $user = lc $3; print "user=$user\n"; $user = ucfirst $user; print "user=$user\n"; my $tmp .= uc (substr $4, 0, 1); print "tmp=$tmp\n"; $user = "$user$tmp"; print "user=$user\n"; %user = ( action => lc $1, mail => lc $2, lname => ucfirst(lc $3), fname => ucfirst(lc $4), rank => uc $5, unit => $6, phone => $7, user => @{[ucfirst(lc $3).uc(substr $4,0,1)]} ); } foreach my $key (keys %user) { print "$key $user{$key}\n"; } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Odd issue with Perl 5.6, l(u)c, and unicode
by mirod (Canon) on Sep 14, 2002 at 08:15 UTC |