That code doesn't exhibit the problem you are trying to solve. (It isn't trying to do anything that requires escaping the slashes.)
Output:
$VAR1 = { 'regex' => { '.*/home/members/index.htm.*' => { '404' => { ' +reporting' => '1000', ' +paging' => '2000' } } } };
Even when I use that key as a regex, it works for me.
#!/usr/bin/env perl use strict; use warnings; use JSON; use Data::Dumper; my $contents = `cat progconfig.json`; my $config = JSON->new->decode($contents); my $re = (keys %{$config->{regex}})[0]; print "re: $re\n"; my $path = '/some/fake/path/home/members/index.html'; if ( $path =~ /$re/ ) { print "$path matched regex\n"; }
Output:
re: .*/home/members/index.htm.* /some/fake/path/home/members/index.html matched regex
In reply to Re^3: Regex in json: escaping forward slash
by Mr. Muskrat
in thread Regex in json: escaping forward slash
by mhearse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |