Re: Perl regrp 101

2004-12-03 Thread Chap Harrison
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 Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; $tmp =~ s/(^\w{3})(.*)/$1/; print "$tmp\n"; FWIW, the above prints "Joe" on my Mac 10.3.6 / Per

Re: Perl regrp 101 -- on OSX.....

2004-12-03 Thread Jay
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 _

Re: Perl regrp 101 -- correction

2004-12-03 Thread Dave Gray
> ## This Does what I want !! > $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; > ($tmp) = $tmp =~ m/^(\w{3})/; > print "$tmp\n"; ## "Joe" > > Why does $tmp need '(...)' ?? Regular expression matches return ($1, $2, ...) in list context. The parentheses force that. -- To unsubscribe,

RE: Perl regrp 101 -- correction

2004-12-03 Thread David Gilden
Ok, > ## This Does what _not_ do what I would expect -- return the first 3 > characters of type '\w' Give this a shot! #!/usr/bin/perl -w use strict; $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; $tmp =~ s/(^\w{3})/$1/; print "$tmp\n"; This returns the whole string ... sorry ab

RE: Perl regrp 101 -- on OSX.....

2004-12-03 Thread David Gilden
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

RE: Perl regrp 101

2004-12-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
David Gilden wrote: > Greetings, > > ## This Does what _not_ do what I would expect -- return the first 3 > characters of type '\w' > > $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; > $tmp =~ s/(^\w{3})(.*)/$1/; > print "$tmp\n"; I ran it and it displayed Joe. What version o

Perl regrp 101

2004-12-03 Thread David Gilden
Greetings, ## This Does what _not_ do what I would expect -- return the first 3 characters of type '\w' $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyot5000"; $tmp =~ s/(^\w{3})(.*)/$1/; print "$tmp\n"; # is ^ better outside the '()s'? $tmp ="Joe Smore1qazxswedcvfrtgbnhytujmkilptyo