On Fri, 3 Dec 2004 10:36:00 -0600, David Gilden <[EMAIL PROTECTED]> wrote: > To David & the group, > > Wags <[EMAIL PROTECTED]> wrote: > > > What version of Perl are running and on what OS > > BBedit under Panther (OSX) Mac -- Berkeley BSD Unix > perl v5.8.1 > > > > > > > ## 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"; > > > I ran it and it displayed Joe. I am running under Windows XP and Perl is > > AS 5.8.4 ( 810 ). > > So the above code in Windows XP does what I expected? Not on my Apple G4! > > > Are you running with strict and warnings? > No > > > Exactly what did your code that you ran look like? > > The above code returned $tmp containing : > "Joe Smore1qazxswedcvfrtgbnhytujmkilptyoXXXXt5000" > No change, that's what has me puzzled > > This is all the code...
In that case, you probably want to add this at the top of it: #!usr/bin/perl use strict; use warnings; Where is the data in $tmp coming from? Cut and pasted? And if so cut and pasted from where? I'm going to guess that one of two things has happend: 1) there are control characters embedded in the string that aren't displying on screen, or there's a unicode issue where whatever you're pasting or saving isn't correctly localized, and isn't getting recognized as matching \w. The issue isn't that /^\w{3}/ is matching the entire string, but that /^\w/ isn't matching at all and the string isn't being modified. Try this: Open a new file in a differnt text editor (TextEdit, SubEthaEdit, pico or emacs in the Terminal), type everything out by hand, and run the script again. I'd be willing to bet this is an issue with BBEdit, not with Perl. BBEdit is a wonderful program, but there are 3,000 settings that can get screwed up...look at how it's handling you text on imports and cut & paste and saving (I'm not a my mac right now, or I'd tell you where to look); There are some ANSI/ASCII/utf8/utf16 conversion settings in there that may be misconfigured. or a leading non-printing control character that's not being stripped. HTH --jay savage -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>