Perl初学笔记之Hello World
作者:junjie 时间:2022-05-21 10:28:55
工作需要开始学Perl,下载个Window版(5.16)的: 下载链接
http://www.activestate.com/activeperl/downloads
安装好了之后,写第一个perl程序
#!/usr/bin/perl
print "Hello,World!\n";
运行结果: (很像Python哦)
c:\Perl>perl HelloWorld.pl
Hello,World!
接着学了下:cpan,虽然不知道这家伙具体是干嘛,应该是能安装各种包,9000多种。
命令如下:看第二次输出的结果,应该是类似于数据库的东东吧。
c:\Perl>cpan App::cpanminus
Set up gcc environment - 3.4.5 (mingw-vista special r3)
CPAN: Term::ANSIColor loaded ok (v4.02)
CPAN: Storable loaded ok (v2.34)
Reading 'C:\Perl\cpan\Metadata'
Database was generated on Fri, 07 Mar 2014 13:06:13 GMT
CPAN: Module::CoreList loaded ok (v2.80)
App::cpanminus is up to date (1.7001).
然后用cpanm安装模块,命令如下: (cpanm Module::Name)
c:\Perl>cpanm YAML
Set up gcc environment - 3.4.5 (mingw-vista special r3)
--> Working on YAML
Fetching http://www.cpan.org/authors/id/I/IN/INGY/YAML-0.90.tar.gz ... OK
Configuring YAML-0.90 ... OK
Building and testing YAML-0.90 ... OK
Successfully installed YAML-0.90
1 distribution installed
如果实在不晓得如何用的话: cpanm --help //-->会看到很多提示。
c:\Perl>cpanm --help
Set up gcc environment - 3.4.5 (mingw-vista special r3)
Usage: cpanm [options] Module [...]
Options:
-v,--verbose Turns on chatty output
-q,--quiet Turns off the most output
看上面的安装过程,好像是可以执行cpanm Link,果然是可以:
c:\Perl>cpanm http://search.cpan.org/CPAN/authors/id/S/SH/SHARYANTO/Alt-Base-0.0
2.tar.gz
Set up gcc environment - 3.4.5 (mingw-vista special r3)
--> Working on http://search.cpan.org/CPAN/authors/id/S/SH/SHARYANTO/Alt-Base-0.
02.tar.gz
Fetching http://search.cpan.org/CPAN/authors/id/S/SH/SHARYANTO/Alt-Base-0.02.tar
.gz ... OK
Configuring Alt-Base-0.02 ... OK
==> Found dependencies: Alt
--> Working on Alt
Fetching http://www.cpan.org/authors/id/I/IN/INGY/Alt-0.04.tar.gz ... OK
Configuring Alt-0.04 ... OK
Building and testing Alt-0.04 ... OK
Successfully installed Alt-0.04
Building and testing Alt-Base-0.02 ... OK
Successfully installed Alt-Base-0.02
2 distributions installed
然后开始写了个文件操作的脚本,里面有个Path::Class模块。
use Path::Class;
C:\Perl\Learn>perl FindFile.pl
Can't locate Path/Class.pm in @INC (@INC contains: C:/Perl/site/lib/MSWin32-x86-
multi-thread C:/Perl/site/lib C:/Perl/lib .) at FindFile.pl line 4.
BEGIN failed--compilation aborted at FindFile.pl line 4.
看提示,像没有安装该包,安装了下该包,结果果然没报这种错误:
C:\Perl\Learn>cpanm Path::Class
Set up gcc environment - 3.4.5 (mingw-vista special r3)
--> Working on Path::Class
Fetching http://www.cpan.org/authors/id/K/KW/KWILLIAMS/Path-Class-0.33.tar.gz ..
. OK
Configuring Path-Class-0.33 ... OK
Building and testing Path-Class-0.33 ... OK
Successfully installed Path-Class-0.33
1 distribution installed
完~
标签:Perl,Hello,World
0
投稿
猜你喜欢
关于程序员生活的一份调查,看看你属于哪一个群体吧
2022-08-11 16:00:48
Mysql环境变量配置方式
2024-01-25 22:41:30
Javascript网页抢红包外挂实现分享
2024-04-16 09:36:02
Sun拟10亿美元收购MySQL
2008-01-17 11:56:00
MySQL索引失效原理
2024-01-19 01:00:50
在IE6中用PNG图片实现半透明效果
2008-05-30 13:14:00
js获取地址栏中传递的参数(两种方法)
2024-04-17 09:54:30
ChatGpt无法访问或错误码1020的几种解决方案
2023-03-03 05:58:36
20个优秀网站助你征服CSS[译]
2008-09-21 13:21:00
python去掉行尾的换行符方法
2021-10-24 02:36:22
手动安装Anaconda环境变量的实现教程
2023-12-09 07:10:27
公网远程访问局域网SQL Server数据库
2024-01-22 01:38:21
在Go程序中实现服务器重启的方法
2024-04-26 17:34:54
Python read函数按字节(字符)读取文件的实现
2021-08-20 09:40:48
简单解决Python文件中文编码问题
2021-08-21 22:58:43
站长必须要了解的九条平面设计常识
2008-06-07 14:33:00
python爬虫headers设置后无效的解决方法
2021-09-04 00:55:17
深入浅出的SQL server 查询优化
2010-07-02 20:58:00
IE8网页显示不正常 用”兼容性视图”搞定
2009-03-28 11:13:00
Python ORM框架Peewee用法详解
2022-11-08 03:00:24