Reputation: 25133
When I do in perl script (source):
`perl -d:DebugHooks::DbInteract='s;e [\@DB::stack\,\@DB::goto_frames]' -e '1'`
The module gets two arguments:
s;e [\@DB::goto_frames\
\@DB::stack];
But I want to get only one:
s;e [\@DB::goto_frames,\@DB::stack];
How to escape ',' sign?
Upvotes: 2
Views: 69
Reputation: 25133
Some people advice me simple approach than patching perl. Just to use =>
in my case:
`perl -d:DebugHooks::DbInteract='s;e [\@DB::stack => \@DB::goto_frames]' -e '1'`
Upvotes: 0
Reputation: 46187
It's got to be your module splitting on the comma, not Running the following under perl
or the shell.bash
, I get only a single argument in @ARGV
:
$ perl -w -E 'say join "\n", ("---", @ARGV, "---")' 's;e [\@DB::stack\,\@DB::goto_frames]'
---
s;e [\@DB::stack\,\@DB::goto_frames]
---
Edit:
I stand corrected. It is being split on commas by perl
, presumably to allow passing multiple arguments to a module, as I proved to myself by creating a module at ./Devel/DbInteract.pm
containing:
package Devel::DbInteract;
use strict;
use warnings;
use 5.010;
sub import {
say 'Received ' . scalar @_ . ' params:';
say join "\n", @_;
}
1;
and running the command:
$ PERL5LIB=. perl -d:DbInteract='s;e [\@DB::stack,\@DB::goto_frames]' -e ''
Received 3 params:
Devel::DbInteract
s;e [\@DB::stack
\@DB::goto_frames]
Judging by the source linked in the asker's answer, there does not appear to be any provision for escaping values or any other way to prevent this splitting. Your options, then, would be to either work around it by join
ing the params back together or submitting a patch to the perl
source to add an allowance for escaping.
Upvotes: 2
Reputation: 25133
Perl does not care about escaping: https://github.com/Perl/perl5/blob/blead/perl.c#L3240-L3264
the -d
flag just add next as zero line number into the script:
use Devel::DbInteract split(/,/,q{s;e [\@DB::stack\,\@DB::goto_frames]});
Upvotes: 0