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

Posted on 2010-01-07
Last Modified: 2012-05-08
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" %*
@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
@rem ';

The code was broken. The issue here is too many single quatation markers: 's. Is there any way to overcome it? Please help.
Question by:jl66
    LVL 28

    Assisted Solution

    Why wrap your perl script inside a batch file?

    If perl was installed correctly, then there is no reason to wrap it in the batch file.  If it wasn't installed correctly, then that problem should be fixed rather than doing a hack like this.

    Author Comment

    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!
    LVL 28

    Accepted Solution

    Try using double quotes instead of the single quotes.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT ( The crux of this batch f…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now