收藏本站 收藏本站
积木网首页 - 技术学院 - 软件测试 - 网站黄页 - 常用手册 - 站长工具 - 技术社区
首页 > perl > 正文

首页 - PHP - 数据库 - 操作系统 - 游戏开发 - JS - Android - MySql - Redis - MongoDB - Win8 - Shell编程 - DOS命令 - jQuery - CSS样式 - Python - Perl

Access - Oracle - DB2 - SQLServer - MsSql2008 - MsSql2005 - Sqlite - PostgreSQL - node.js - extjs - JavaScript vbs - Powershell - Ruby

Perl初学笔记之Hello World

工作需要开始学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:PerlcpanMetadata'  

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:PerlLearn>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:PerlLearn>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学习笔记之CPAN使用介绍
CPAN(ComprehensivePerlArchiveNetwork:全面的Perl存档网络)是查找任何Perl有关的东西的中心仓库。它包含从整个Perl社区收集来的智慧:成百上千的Perl模块和脚

Perl学习笔记之文件操作
Perl对文件的操作,跟其它的语言类似,无非也就是打开,读与写的操作。1.打开文件#!c:/perl/bin/perl-wuseutf8;usestrict;usewarnings;my$filename='test.txt';#或者用绝对

About Perl(翻译Perl官网介绍)
强大,稳定,成熟,可移植性Perl5是一门有着26年历史的,功能强大的、性能丰富的编程语言。Perl能在超过100种的平台上运行,从便携式设备到大型主机。同

本周排行

更新排行

强悍的草根IT技术社区,这里应该有您想要的! 友情链接:b2b电子商务
Copyright © 2010 Gimoo.Net. All Rights Rreserved  京ICP备05050695号