I've got a file that contains strings that look like this: ITEM-####, which I would like to transform into something I can use to make Perl check against like items in our database, for example: ITEM-1234.
I thought I might achieve this with something simple like
but to no avail. Instead I got a warning: "Unrecognized escape \d passed through."my $string = qw(ITEM-####); $string =~ s/#/\d/g;
So then I tried escaping the escape, like so:
But that makes my string look like this: ITEM-\\d\\d\\d\\d, which isn't what I'm looking for.my $string = qw(ITEM-####); $string =~ s/#/\\d/g;
My last idea was to use qw...
But that also got expanded to include two back slashes: ITEM-\\d\\d\\d\\d.my $esc = qw(\d); my $string = qw(ITEM-####); $string =~ s/#/$esc/g;
So now I'm stumped. Is there any way I can do this? Li'l help?
Update: FunkyMonk is right, my code does work. I was looking at it in the debugger, and apparently the debugger itself was adding the extra backslash. Thank you both.
--starX
www.axisoftime.com
In reply to Solved: Escaping Escapes by starX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |