[OT] escape a dot in perl

Colin Watson cjwatson at ubuntu.com
Fri Nov 18 20:32:14 UTC 2005


On Fri, Nov 18, 2005 at 08:54:52PM +0100, Thomas Kaiser (ubuntu) wrote:
> Sorry, I know this is off topic, but maybe somebody has an answer :-)
> 
> Why does
> @title = split ("\.\./", $line);
> and
> @title = split ("../", $line);
> give me the same results.

\ is an escape character within double quotes, so "\." is identical to
".". Use '\.\./' (note single quotes) instead, or perhaps use m{\.\./}
to make it more explicit that '\.\./' is really a regular expression.

-- 
Colin Watson                                       [cjwatson at ubuntu.com]




More information about the ubuntu-users mailing list