Remember to always group reply so others can help and be helped.
David Gilden wrote:
Why am I getting 'one two three' in $s and not just 'one'
You might want to print $1, this will give you a better idea. $1 is
being set to everything in the parentheses, which is everything you
match, and the
David Gilden wrote:
In the following why am I getting '23'
Is 23 being treated as a string?
Not exactly. It is NOT being treated as a number if that is what you
mean, all of $s is being treated as a string. Specifically \w matches
any "word" character, which is any alphanumeric...so [A-Za-z0-9_].
In the following why am I getting '23'
Is 23 being treated as a string?
#!/usr/bin/perl -w
use strict;
my $s = ' 23 one two three';
$s =~ s/(\w{1,10}).+/$1/;
print $s;
---
my $s = 'one two three';
$s =~ s/(\w)/$1/;
print $s;
Returns 'one two three', I was looking for it to match 'on