Link to home
Start Free TrialLog in
Avatar of jl66
jl66Flag for United States of America

asked on

How to put the special character in a mix of perl and dos shell program?

Please read the snippet of code from one of your experts:
@rem = 'Perl, ccperl will read this as an array of assignment & skip this block
@CD /d "%~dp0"
@perl -s "%~nx0" %*
@GOTO:EOF
@rem ';
 
#Start your perl script below
my @fruits = ('apple', 'orange', 'grapes', 'banana');
 
foreach my $item (@fruits) {
    print $item . "\n";
}
Which works perfectly.However I would like to one line code in the DOS shell portion.
@rem = 'Perl, ccperl will read this as an array of assignment & skip this block
@CD /d "%~dp0"
@perl -s "%~nx0" %*
REM add the line below
@for /F "tokens=3" %%i in ('REG QUERY HKLM\Software\Perl /v BinDir') do set perlexe=%%i
REM end of line
@GOTO:EOF
@rem ';

The code was broken. The issue here is too many single quatation markers: 's. Is there any way to overcome it? Please help.
SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jl66

ASKER

Thank you FishMonger.
To fix some lagacy code. I have to OVERCOME IT.  Please consider
@rem = 'Perl,
...
.... in ('REG ...BinDir') ...
...
@rem ';
The 's make the big difference!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial