如何使用Strawberry Perl运行程序? [英] How do I run programs with Strawberry Perl?

查看:604
本文介绍了如何使用Strawberry Perl运行程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个同事试图在Windows机器上使用 ack (一种Perl程序),并在Linux下进行了尝试,他肯定要使用它.他设法在自己的计算机上安装了 Strawberry Perl ,但似乎无法弄清楚该如何做才能确认.从命令提示符运行它.他尝试编辑#!线,但我知道那是行不通的.我很确定Strawberry Perl在他的PATH中.

A coworker is trying to use ack (a Perl program) on his Windows machine, having tried it under Linux and decided he definitely wants to use it. He managed to get Strawberry Perl installed on his machine, but can't seem to figure out what to do to make ack run with it from a command prompt. He tried editing the #! line, but I knew that wouldn't work. I'm pretty sure Strawberry perl is in his PATH.

使用草莓在Windows上的PATH中运行常规Perl程序需要做什么?

What do you need to do to run a general Perl program in your PATH on Windows using Strawberry?

更新:我在线上看到一些有关PATHEXT变量的信息,但还不够.

Update: I'm seeing some information online about the PATHEXT variable, but not enough.

推荐答案

首先,请注意程序位于Path中,而不仅仅是perl.exe中. Perl二进制文件和核心程序通常位于<installdir>\bin中,但其他程序可能最终位于站点特定的目录<installdir>\site\bin中.命令

First, be careful that the program is in the Path, not just perl.exe. The Perl binaries and core programs usually end up in <installdir>\bin, but others may end up in the site specific directory <installdir>\site\bin. The command

dir C:\strawberry\ack* /s

可能会帮助您进行搜索.确保您的Path反映了您的设置.

might aid your search. Make sure your Path reflects your setup.

从Windows命令提示符中运行Perl程序有两种常见的方法,至少我是知道的.

There are two common ways, at least that I know of, to run a Perl program from the Windows Command Prompt.

第一个方法是使用 pl2bat ,它将与程序一起执行perl.安装的程序通常会自动执行此操作,因为MakeMakerModule::Build会处理此问题.

The first is to create a batch version of the program with pl2bat, which will execute perl with the program. Installed programs usually do this automatically because MakeMaker and Module::Build take care of this.

第二个是创建.pl文件关联.这是通过创建注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pl\Shell\Open\Command(或HKEY_CURRENT_USER(仅用于当前用户))并将(Default)值设置为

The second is to create a .pl file association. This is done by creating the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.pl\Shell\Open\Command (or HKEY_CURRENT_USER if it's for the current user only) and set the (Default) value to

"C:\strawberry\perl\bin\perl.exe" "%1" %*

这样,您可以仅通过使用.pl扩展名将其命名来调用程序.现在,您可以使用program.pl调用程序.

That way, you can call programs just by naming them with the .pl extension. Now you can invoke the program with program.pl.

您可能已经注意到,可以在不带扩展名的Windows上调用程序.在Path中搜索该程序,但是当没有扩展名时,将使用PATHEXT来完成该名称.将.pl追加到列表中,就可以使用program来调用该程序.请注意,此列表中的顺序对于搜索很重要,就像Path中的顺序很重要.

You may have noticed that you can call a program on Windows without the extension. The program is searched for in the Path, but when there's no extension, PATHEXT is used to complete the name. Append .pl to the list, and you can invoke the program just with program. Note that the order in this list is important for the search, just as the order in Path matters.

安装程序通常会处理最后两个步骤,但是如果您要添加自己的内容或需要对其进行修复,则此知识很有用.

Installers usually take care of the last two steps, but this knowledge is useful if you'd like to add your own or need to fix it.

这篇关于如何使用Strawberry Perl运行程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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