Next | Regular Expression Mastery | 44 |
This brings up a subtlety:
$time = <STDIN>; # "11:29\n" ($minutes) = ($time =~ /:(.*)$/);
If . doesn't match \n, why does this pattern match succeed?
The string ends with \n, and . won't match \n.
Answer: $ doesn't have to be exactly at the end. It will match at a \n that is at the end.
Next | Copyright © 2002 M. J. Dominus |