Perl和批处理可以在同一个批处理文件运行? [英] Can Perl and Batch run in the same batch file?

查看:206
本文介绍了Perl和批处理可以在同一个批处理文件运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个批处理脚本,做一些处理,并要求一些Perl脚本。

I've got a batch script that does some processing and calls some perl scripts.

我的问题是,如果有把perl的code直接进入批处理脚本,并使其运行两种类型的脚本的方式。

My question is if there was a way to put the perl code directly into the batch script and have it run both types of scripts.

推荐答案

活跃的Perl 一直在做了多年!

下面是一个骨架。你只能调用perl的的一次的虽然。因为它传递 -x 开关说,你会发现perl的code的嵌入式的这个文件,和perl读下文件,直到找到一个Perl的家当(#!... perl的),并开始执行那里。 Perl会忽略一切都会过去的 __结束__ 键,因为你告诉DOS到转到endofperl 它不会与任何东西,直到它打扰获取到的标签。

Below is a skeleton. You can only call perl once though. Because passing it the -x switch says that you'll find the perl code embedded in this file, and perl reads down the file until it finds a perl shebang (#!...perl) and starts executing there. Perl will ignore everything past the __END__ and because you told DOS to goto endofperl it won't bother with anything until it gets to the label.

@rem = '--*-Perl-*--
@echo off
perl -x -S %0 %*
goto endofperl


@rem -- BEGIN PERL -- ';
#!d:/Perl/bin/perl.exe -w
#line 10

use strict; 


__END__
:endofperl

这篇关于Perl和批处理可以在同一个批处理文件运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆