Hello Wise Monks,
I'm trying to find a more efficient solution, to correct interpolated data coming into my script.
Since I cannot control the data coming in - only how its stored in the database.
I'm storing data into a SQL database that is interpolating domain accounts into whitespace.
Incoming data, 3 types of samples interpolated:
"AD\thomas" -> "AD homas" # tab "MAIN\nancy" -> "MAIN ancy" # newline "nancy" -> "nancy" # no domain, no problem
Here is what I came up with, but its a kludge, and not efficient when working with lots of database inserts.
$domainID =~ (s/(AD|MAIN)\n/n/); # should not be $domainID =~ (s/(AD|MAIN)\r/r/); # checked 3 times $domainID =~ (s/(AD|MAIN)\t/t/); # before exiting
- - - SOLUTION - - -
Thanks to everyone's suggestions, I solved this domain interpolation issue:
our %whitespace = ( "\f" => "f","\n" => "n","\r" => "r","\t" => "t" ); $netid =~ (s/(\s)/$whitespace{$1}/g); $netid =~ (s/(AD|MAIN)//);
Results:
"AD\thomas" -> "thomas" "MAIN\floyd" -> "floyd" "AD\manny" -> "manny" # perl escapes normal char, no harm
Thank you for all the help,
jcrushIn reply to Efficiently create an IF/ELSE regex by jcrush
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |