in reply to Re^5: Checking input
in thread Checking input
I disagree. Consider the code:
By your reasoning $bar should be '\'. It isn't. This script prints#!/usr/bin/perl $foo = "this is a \\ test"; print "Foo: ($foo)\n"; ($bar) = $foo =~ /([\-])/; print "Bar: ($bar)\n";
Foo: (this is a \ test) Bar: ()
Change $foo to "this is a \\ test - " and $bar becomes '-', not '\'. The \ before the - in the character class [\w\-] isn't escaping anything, true. But it doesn't get added to the character class.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Checking input
by diotalevi (Canon) on Feb 25, 2003 at 23:46 UTC | |
by Nkuvu (Priest) on Feb 25, 2003 at 23:57 UTC |