On Dec 3, 2004, at 10:10 AM, David Gilden wrote:
## 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";

FWIW, the above prints "Joe" on my Mac 10.3.6 / Perl 5.8.1, preceded only by #!/usr/bin/perl.


This does, too (get in the habit of starting every script w/the following three lines, it's always the first question you'll be asked and it's a good idea besides ;-)

#!/usr/bin/perl
use strict;
use warnings;

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


Chap


-- 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