perl执行程序问题,如何在它运行中加入参数

perl执行程序问题,如何在它运行中加入参数,第1张

$ cat tpl

use strict;

use warnings;

my $var1 = $ARGV[0];

my $var2 = $ARGV[1];

print "you input argment1 = '$var1'\n";

print "you input argment2 = '$var2'\n";

$ perl tpl 123 abc

you input argment1 = '123'

you input argment2 = 'abc'

$

dos命下执行perl脚本方法:

1、输入 perltestpl然后就能执行了。

2、其中testpl是所要运行的文件的名称。

3、用命令指示符则说不是内部或外部的命令。

4、这个说明安装没有自动把perl的文件路径自动添加到环境变量中去。

具体方法:右击 的电脑--属性--高级--环境变量--在系统变量部分--双击path--在最后添加perl的安装路径即可。

perl有两种运行方式,比较常用的是以脚本的形式,还有一种就是在命令行下直接运行。

先说脚本形式如果不会vi的话,你可以用图形界面的文本编辑器,在ubuntu下新建一个文本文件,以pl作为后缀,这样打开就可以以perl的形式高亮显示了。

然后在里面输入perl脚本程序,保存,chmod u+x testpl,这样可以使其成为可执行文件,在命令行下直接/testpl就可以运行了。

第一是,perl文件的第一行要指定perl解释器的位置,典型的如下

#!/usr/bin/perl

第二是,perl文件的权限要有可执行的权限,可通过右键->属性->权限,勾选来添加可执行权限(当然,你本身也应该有修改该文件权限的权限),也可以通过在命令行上执行chmod +x <perlfile>来添加执行权限。

path中有冲突。根据查询perl脚本可知perl环境变量设置好因为path中有冲突所以在cmd下无法运行。Perl种功能丰富的计算机程序语言,运行在超过100种计算机平台上,适用广泛。

用搜索找到perlexe文件,在你的安装目录里,然后把它所在的目录添加到PATH里。无法运行的原因是 *** 作系统找不到这个文件,你试试打出全部路径就能运行,而添加PATH后直接打perl就可以运行,至于添加办法,打开C:\autoexecbat找到PATH那一行,添加路径到那一行即可。另外在cmd里输入PATH=$PATH;路径也行。这些你搜索一下添加PATH查看详细的知识吧

在装好了Perl的电脑上,运行perldoc即可查看。

首先可以输入perldoc perl查看perl概览。

输入perldoc perldoc查看perldoc的用法。

perldoc -f PerlFunc即可查看perl的函数说明;

例如perldoc -f lc,就可以查看函数lc的说明。

输入perldoc perlfaq1,把1变成19可以查看perl如下常见问题答疑;

perlfaq1 - General Questions About Perl

perlfaq2 - Obtaining and Learning about Perl

perlfaq3 - Programming Tools

perlfaq4 - Data Manipulation

perlfaq5 - Files and Formats

perlfaq6 - Regular Expressions

perlfaq7 - General Perl Language Issues

perlfaq8 - System Interaction

perlfaq9 - Web, Email and Networking

输入perldoc ModuleName可以查看perl模块自带说明;

例如 perldoc Tk::Hlistplus可以查看Tk::Hlistplus这个模块自带的使用说明文档。(当然如果这个模块没有安装,则会显示No documentation found for Tk::Hlistplus)。

例如输入perldoc perlreftut可以查看perl的引用教程,把perlreftut换成如下,可以查看这些条目的perl官方教程:

perlreftut - Mark's very short tutorial about references

perldsc - data structure complex data structure struct

perllol - Manipulating Arrays of Arrays in Perl

perlrequick - Perl regular expressions quick start

perlretut - Perl regular expressions tutorial

perlboot - Links to information on object-oriented programming in Perl

perlootut - Object-Oriented Programming in Perl Tutorial

perltoot - Links to information on object-oriented programming in Perl

perltooc - Links to information on object-oriented programming in Perl

perlbot - Links to information on object-oriented programming in Perl

perlstyle - Perl style guide

perlcheat - Perl 5 Cheat Sheet

perltrap - Perl traps for the unwary

perldebtut - Perl debugging tutorial

perlopentut - simple recipes for opening files and pipes in Perl

perlpacktut - tutorial on pack and unpack

perlthrtut - Tutorial on threads in Perl

perlxstut - Tutorial for writing XSUBs

perlunitut - Perl Unicode Tutorial

perlpragma - how to write a user pragma

输入perldoc 如下关键词可以查看perl参考;例如输入perldoc perlvar可以查看系统预定义的perl变量说明:

perlsyn - syntax

perldata - Perl data types

perlsub - subroutine function

perlop - operator

perlfunc - function

perlpod - POD plain old documentation

perlpodspec - Plain Old Documentation: format specification and notes

perlpodstyle - Perl POD style guide

perldiag - various Perl diagnostics

perllexwarn - Perl Lexical Warnings

perldebug - debug debugger

perlvar - Perl predefined variables

perlre - regular expression regex regexp

perlreref - Perl Regular Expressions Reference

perlrebackslash - Perl Regular Expression Backslash Sequences and Escapes

perlrecharclass - character class

perlref - reference pointer data structure structure struct

perlform - format report chart

perlobj - object OOP

perltie - tie

perldbmfilter - Perl DBM Filters

perlipc - Perl interprocess communication (signals, fifos, pipes, safe subprocesses, sockets, and semaphores)

perlfork - Perl's fork() emulation

perlnumber - semantics of numbers and numeric operations in Perl

perlperf - Perl Performance and Optimization Techniques

perlport - Writing portable Perl

perllocale - Perl locale handling (internationalization and localization)

perluniintro - Perl Unicode introduction

perlunicode - Unicode support in Perl

perluniprops - Index of Unicode Version 800 character properties in Perl

perlunicook - cookbookish examples of handling Unicode in Perl

perlebcdic - Considerations for running Perl on EBCDIC platforms

perlsec - Perl security

perlmod - Perl modules (packages and symbol tables)

perlmodlib - constructing new Perl modules and finding existing ones

perlmodstyle - Perl module style guide

perlmodinstall - Installing CPAN Modules

perlnewmod - preparing a new module for distribution

perlfilter - Source Filters

perlglossary - Perl Glossary

perlexperiment - A listing of experimental features in Perl

perldtrace - Perl's support for DTrace

CORE - Namespace for Perl's core routines

perldoc -v PerlVar可以查看Perl的变量说明:

例如输入perldoc -v $$可以看到$$的解释;

如果某些变量直接跟在-v后面识别不了,可以用双引号引起来,例如可以输入perldoc -v "$|" 查看变量$|的如下说明:

C:\>perldoc -v "$|"

HANDLE->autoflush( EXPR )

$OUTPUT_AUTOFLUSH

$| If set to nonzero, forces a flush right away and after every

write or print on the currently selected output channel Default

is 0 (regardless of whether the channel is really buffered by

the system or not; $| tells you only whether you've asked Perl

explicitly to flush after each write) STDOUT will typically be

line buffered if output is to the terminal and block buffered

otherwise Setting this variable is useful primarily when you

are outputting to a pipe or socket, such as when you are running

a Perl program under rsh and want to see the output as it's

happening This has no effect on input buffering See "getc" in

perlfunc for that See "select" in perlfunc on how to select the

output channel See also IO::Handle

Mnemonic: when you want your pipes to be piping hot

以上就是关于perl执行程序问题,如何在它运行中加入参数全部的内容,包括:perl执行程序问题,如何在它运行中加入参数、如何在dos窗口执行perl代码、求助,perl写的程序如何在ubuntu中运行等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9309451.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-27
下一篇2023-04-27

发表评论

登录后才能评论

评论列表(0条)

    保存