wrote:
> I have the following code...my only question is in line 4. where you
> see the ^ and $ (last one) character which means start/end of the
> string. But my question is where does it stop matching for the caret
> and the dollar sign ?
I don't understand what you're asking. What does "stop matching" mean?
There is no start or stop to the matching. The ^ matches exactly once
- at the beginning of the string. The $ matches exactly once - at the
end of the string [1].
> I think the caret is everything from the beginning of the string all
> the way to the end and same when matching from the end of the line it
> matches everything to the start of the string.
No, the caret matches ONLY the beginning of the string. It does not
match any characters that follow the beginning of the string. Same
applies to the $ for the end.
> There is nothing to tell
> it to stop ? Does this sound correct ?
No, because there is no concept of "stopping". I think you are
confusing the ^ and $ anchors with the + or * quantifiers.
> 4. if($line =~ /^$user:$password$/)
This says: "If $line matches the beginning of the string, the variable
$user, a colon, the variable $password, and the end of the string".
That is, $line must contain *nothing* but $user, colon, $password.
Nothing can come before or after that, or the pattern match fails.
Paul Lalli