Re: question on pattern matching

2006-03-07 Thread Tom Phoenix
On 3/7/06, Gavin Bowlby <[EMAIL PROTECTED]> wrote: > So > > (\.)? > > differs from > > (\.?) > > in that there is no match in the first case, but there is a match in the > second case? Well, to be sure, we're talking about a successful pattern match in either case. But the first one has a quantifi

Re: question on pattern matching

2006-03-07 Thread Shawn Corey
Gavin Bowlby wrote: So (\.)? differs from (\.?) in that there is no match in the first case, but there is a match in the second case? I'm still confused as to why the placement of the ? operator inside or outside the parentheses makes a difference. I thought the parentheses were only there

RE: question on pattern matching

2006-03-07 Thread Gavin Bowlby
esult to a $N variable, not to change the operations of the pattern matching itself. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix Sent: Tuesday, March 07, 2006 6:51 PM To: Gavin Bowlby Cc: beginners@perl.org Subject: Re: question on pattern mat

Re: question on pattern matching

2006-03-07 Thread Tom Phoenix
On 3/7/06, Gavin Bowlby <[EMAIL PROTECTED]> wrote: > Could someone explain why the first case fails? It's not failing. It's warning. It's warning you that you're using an undefined value as if it were a string. That's odd, Perl is saying, you seem to have expected $3 to hold a string. But since

question on pattern matching

2006-03-07 Thread Gavin Bowlby
#!/usr/bin/perl use warnings; use strict; my ($x, $y); $x = "57 s"; # the following statements fail: $x =~ /^(\s*)(\d+)(\.)?(\d*)(\s*)(s|S)/; $y = $1.$2.$3; # FAILS with "Use of uninitialized value in concatenation (.) or string" # because $3 is undefined # whereas these statements pass: $x =~