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
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 _
> ## 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,
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
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
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
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