in reply to Passing regex to a subroutine
Another debugging approach is to ask what all those strings look like when they're concatenated together inside the function.
>perl -wMstrict -le "my $regexStr = qr{[0-9]+}; my $suff = '.dn'; my $getDir = 'c:\sh\\'; ;; my $concat = qq{$getDir$regexStr$suff}; print qq{for debug: '$concat'}; " for debug: 'c:\sh\(?^:[0-9]+).dn'
The first thing that catches the eye is that (?^:[0-9]+) stuff in the middle of everything. What's that about? Clearly, it derives from the regex, but how does it relate to the specification of a path and file name? (Of course, one quickly realizes it is the stringization of the Regexp regex object – not a string at all – that qr// produces.)
Seeing the inappropriate nature of the data being fed to the Windoze dir command is the first step toward thinking more clearly about what one ought to be doing.
|
|---|