jl66
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.
@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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
To fix some lagacy code. I have to OVERCOME IT. Please consider
@rem = 'Perl,
...
.... in ('REG ...BinDir') ...
...
@rem ';
The 's make the big difference!