Greetings,

## This Does what _not_ do what I would expect  -- return the first 3  
characters of type '\w'

$tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyoXXXXt5000";
$tmp =~ s/(^\w{3})(.*)/$1/;
print "$tmp\n";  

# is ^ better outside the '()s'?

####
$tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyoXXXXt5000";
($tmp) =  $tmp =~ s/(^\w{3})(.*)/$1/;
print "$tmp\n";   # name  contains "1"  not "Joe"

# $1 captures "Joe" --- but 

## This Does what I want !!
$tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyoXXXXt5000";
($tmp) = $tmp =~ m/^(\w{3})/;
print "$tmp\n"; ## "Joe"

The above code works fine but I am not sure on reading the syntax 
-- and would this qualify as untainting data? -- and yes I realize we are 
clobbering $tmp


Thanks & Happy Holidays -- from Cow Town

Dave Gilden

(kora musician / audiophile / webmaster @ www.coraconnection.com  / Ft. Worth, 
TX, USA)

PS: Please reply to me off list (and CC the list so that others can benefit!)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to