The database contains company names that have single quotes within the name. When the user selects a company, I need to retrieve from a hash with the key=CompanyName. Problem I'm having is not being able to retrieve the contents from Stash.
In Debug mode, I've validated the following, able to use single quotes and double quotes around the company name:
DB<12> x $c->stash->{'company_list'}->{'corp_summary'}->{'Waldo\\\'s Merchandising Services, LLC'}
0 'c635|i1193|i1194|i1220|i1221|'
DB<13> x $c->stash->{'company_list'}->{'corp_summary'}->{"Waldo\\\'s Merchandising Services, LLC"}
0 'c635|i1193|i1194|i1220|i1221|'
The code prints out the name I'm looking for and the replacement I've done, yet the last line of code "$codes" remains empty.
306 print "$cc\n";
307 print "$cc\n";
308 print "$cc\n";
309 print "$cc\n";
310 my $temp = $cc;
311 $temp =~ s/'/\/\/\/\'/g;
312
313 print "$temp\n";
314 print "$temp\n";
315 print "$temp\n";
316 print "$temp\n";
317 print "$temp\n";
318 my $codes = $c->stash->{'company_list'}->{'corp_summary'}->{"$temp"};
Output from print statements:
Waldo's Merchandising Services, LLC
Waldo's Merchandising Services, LLC
Waldo's Merchandising Services, LLC
Waldo's Merchandising Services, LLC
Waldo///'s Merchandising Services, LLC
Waldo///'s Merchandising Services, LLC
Waldo///'s Merchandising Services, LLC
Waldo///'s Merchandising Services, LLC
Waldo///'s Merchandising Services, LLC
My expected output is to have $codes to contain "c635|i1193|i1194|i1220|i1221|"
You are using forward slashes instead of backslashes and you have two more slashes than needed in $temp
. Try:
$temp =~ s{'}{\\'}g;