Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2010-01-07
3
Medium Priority
?
339 Views
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" %*
@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.
0
Comment
Question by:jl66
  • 2
3 Comments
 
LVL 28

Assisted Solution

by:FishMonger
FishMonger earned 2000 total points
ID: 26205008
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.
0
 

Author Comment

by:jl66
ID: 26205100
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!
0
 
LVL 28

Accepted Solution

by:
FishMonger earned 2000 total points
ID: 26205187
Try using double quotes instead of the single quotes.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). 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…
Six Sigma Control Plans
Suggested Courses

564 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