I'm using such an excellent reference right now, that even the book samples dont work. All pun intended
Referring to and it says this:
"The x option tells the Perl interpreter to ignore all white space unless preceded by a backslash. As with the pattern-matching operator, ignoring white space makes complicated string patterns easier to read.
$string =~ s/\d{2} ([\W]) \d{2} \1 \d{2}/$1-$2-$3/xThis converts a day-month-year string to the dd-mm-yy format.
Now the question is this: These special built in variables namely $1, $2 that store the value of pattersn in parentheses SHOULD in theory match the pattern
([\W])
So obviously, $1,$2,$3 contain just the value "/", so how is this string substitution to work?
For all purposes (as I understand it) THIS should work: $string =~ s/(\W)/-/x;
Am I missing something here?
Thanks.Edited by castaway - added code tags.
In reply to String Substitution Operator by hehenoobhehe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |