`
lobin
  • 浏览: 417799 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Perl

 
阅读更多

Perl on windows platform

 

ActivePerl

 

http://www.activestate.com

 

Installation

 

http://www.activestate.com/activeperl/downloads

 

Perl Binaries:

ActivePerl-5.14.2.1402-MSWin32-x86-295342.msi

 

 

Suppose you install ActivePerl under below dir:

 

D:\usr\bin\Perl\Perl5.14.2

 

Configuration ActivePerl on windows platform

 

If you do not select the option to set the installation direction into env %PATH%,

you need do something belows additional:

 

set %PATH% = %PATH%;D:\usr\bin\Perl\Perl5.14.2\bin;D:\usr\bin\Perl\Perl5.14.2\site\bin;

 

Test

 

>perl

D:\home\admin\workstation\perl>perl

 

 

 

>perl -version

 

D:\home\admin\workstation\perl>perl -version

This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

Binary build 1402 [295342] provided by ActiveState http://www.ActiveState.com
Built Oct  7 2011 15:49:44

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

>ppm

 

see Diagram 1,2

 

Installation - DBI module

 

ppm

 

command to open Perl Package Manager tool.

 

ppm provides gui tool to install perl packages.

 

or

 

ppm install DBI

 

Installation - DBD MYSQL

 

ppm

 

or

 

ppm install DBD-mysql

 

例子

#

# Program to calculate the circumference of circle

# The constant variable of PI
$pi = 3.14159265;



# This section is to calculate the circumference of circle
# (whose radius is 12.5)
$radius = 12.5;

$cc = 2*$pi*$radius;

print $cc;
print "\n";

print "The circumference of circle(radius=$radius): $cc\n";

print "The circumference of circle(radius=".$radius."): ".$cc."\n";


# This section is to calculate the circumference of circle, 
# which the radius of circle inputed from termine by user.
# So, pls enter the radius of circle while "Pls input the radius of circle".
# User can exit the program by click <ENTER> key.
print "Pls input the radius of circle:";
while ($radius = <STDIN>) {
    if ($radius eq "\n") {
        print "exit";
        last;
    }

    if ($radius < 0) {
        print "Warn: The radius of circle can not be less than zero(0)\n";
        $cc = 0;
    } else {
        $cc = 2*$pi*$radius;
    }
    print "The circumference of circle(radius=".$radius."): ".$cc."\n";

    #continue yes/no
    print "Pls input the radius of circle:";
}

 

 Another Perl Practice(ActivePerl On Window Platform) 

 

$count = 5;
$ss = "12345";

print "$ss\n" x $count;
print "--------------------------\n";


print "Pls input a string: ";
$ss = <STDIN>;

print "Pls the count of string to display: ";
$count = <STDIN>;
print "$ss\n" x $count;
print "--------------------------\n";


while (1) {
    print "Pls input a string: ";
    $ss = <STDIN>;
    if ($ss == "\n") {
        print "exit";
        last;
    }

    print "Pls the count of string to display: ";
    while ($count = <STDIN>) {
        if ($count != "\n") {
            last;
        }
        print "Pls the count of string to display: ";
    }

    print "$ss\n" x $count;
    print "--------------------------\n";
}

 

One Perl Practice With Database MYSQL

mysql_select.pl:

 

use strict;
use DBI;
#my($dbh) = DBI->connect("DBI:mysql:it-community", "root", "jxcoco1128", "") or die "can't connect!\n";
my $dbh = DBI->connect("DBI:mysql:database=it-community;host=localhost", "root", "jxcoco1128", {'RaiseError'=>1});

my $sql = "select * from micro_blogging";
my $sth = $dbh->prepare($sql);
$sth->execute();
print "======================================================================================================================\n";
#
while (my @array=$sth->fetchrow_array())
{
printf("%-35s", $_) foreach(@array);
print "\n----------------------------------------------------------------------------------------------------------------------\n";
};
print "======================================================================================================================\n";
$dbh->disconnect();
exit 0;

 

 

perl mysql_select.pl:

 

D:\home\admin\workstation\perl>perl mysql_select.pl
======================================================================================================================
1                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
10                                 微博信息                           描述内容                           用户名
----------------------------------------------------------------------------------------------------------------------
2                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
3                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
4                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
5                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
6                                  c1                                 d1                                 u1
----------------------------------------------------------------------------------------------------------------------
7                                  c1                                 d1                                 用户名
----------------------------------------------------------------------------------------------------------------------
8                                  微博信息                           描述内容                           用户名
----------------------------------------------------------------------------------------------------------------------
9                                  微博信息                           描述内容                           用户名
----------------------------------------------------------------------------------------------------------------------
======================================================================================================================

 

Example of  front end web development  base perl

 

#!D:/usr/bin/Perl/Perl5.14.2/bin/perl.exe

use strict;
use DBI;
use CGI;


my $q = new CGI;
#my $q = CGI->new;
my $topicID = $q->param('id');
print "Topic ID: $topicID\n";

print "Content-type: text/plain; charset=GBK\n\n";

#my($dbh) = DBI->connect("DBI:mysql:it-community", "root", "password", "") or die "can't connect!\n";
my $dbh = DBI->connect("DBI:mysql:database=it-community;host=localhost", "root", "password", {'RaiseError'=>1});

$dbh->do("SET character_set_client = 'gbk'");
$dbh->do("SET character_set_connection = 'gbk'");
$dbh->do("SET character_set_results= 'gbk'");



my $sql = "select uuid, comments, submitter, UNIX_TIMESTAMP(timestamp) creation_timestamp from topic_tie where topic_id='".$topicID."'";
my $sth = $dbh->prepare($sql);
$sth->execute();

# print "======================================================================================================================\n";


# <tr>
# <td>楼主</td>
# <td>
#     <div style="width: 100%; border-radius: 6px 6px 6px 6px; -moz-border-radius: 6px 6px 6px 6px; border: 1px solid silver;">
#         <div style="height: 28px; width: 100%; border-radius: 6px 6px 0px 0px; -moz-border-radius: 6px 6px 0px 0px; border: 1px solid silver;">
#             <span style="line-height: 28px;"><label>标题:</label></span>
#         </div>
#         <div style="height: 28px; width: 100%; border-radius: 0px 0px 6px 6px; -moz-border-radius: 0px 0px 6px 6px; border: 1px solid silver;">
#                            
#         </div>
#     </div>
# </td>
# </tr>


# <tr>
#     <td width="150"></td>
#     <td><a href="">回复主题</a></td>
# </tr>

#while (my @array=$sth->fetchrow_array()) 
#{
# printf("%-35s", $_) foreach(@array);
# print "\n----------------------------------------------------------------------------------------------------------------------\n";
#};

my $ttt = time();
while (my $ref = $sth->fetchrow_hashref()) {
    print ("<tr>\n");
    print "<td>\n";
    print "$ref->{'deliver'}\n";
    print "</td>\n";

    print "<td>\n";
    print "<div style='width: 100%; border-radius: 6px 6px 6px 6px; -moz-border-radius: 6px 6px 6px 6px; border: 1px solid silver;'>\n";
    print "<div style='height: 28px; width: 100%; border-radius: 6px 6px 0px 0px; -moz-border-radius: 6px 6px 0px 0px; border: 1px solid silver;'>\n";
    
    print "<span style='line-height: 28px;'>\n";
    print "<label>\n";
    print "标题:\n";
    my $_id = $ref->{'uuid'};
    my $_timestamp = $ref->{'creation_timestamp'};
    my $temp = $_timestamp + 86400;
    #print ("</tr>$_timestamp     $temp   $ttt\n");
    if ($temp >= $ttt) {
        print ("<img src='images/new_icon.gif' title='最新论坛主题!'/>");
    }
    print "<a href='tp.shtml?id=".$_id."'>".$ref->{'name'}."</a>(于$ref->{'last_updatetime'}更新)\n";
    print "</label>\n";
    print "</span>\n";
    print "</div>\n";
    print "<div style='height: auto; width: 100%; border-radius: 0px 0px 6px 6px; -moz-border-radius: 0px 0px 6px 6px; border: 1px solid silver;'>\n";
    print "$ref->{'comments'}\n";
    print "</div>\n";
    print "</div>\n";
    print "</td>\n";
    print ("</tr>\n");


    print "<tr>\n";
    print "<td width='150'></td>\n";
    print "<td><a href=''>主页</a>|<a href=''>资料</a>|<a href=''>短信</a>|<a href=''>留言</a>|<a href=''>关注</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=''>好</a>|<a href=''>差</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=''>引用</a>|<a href=''>收藏</a></td>\n";
    print "</tr>\n";
}


# while (my $ref = $sth->fetchrow_hashref()) {
#    print "uuid: $ref->{'uuid'}\n";
#    print "commects: $ref->{'comments'}\n";
#    print "descr: $ref->{'descr'}\n";
#    print "username: $ref->{'username'}\n";
#    print "------------\n";
#}

# print "======================================================================================================================\n";
$dbh->disconnect();
exit 0;

 

 

 

 

 

 

  • 大小: 40.9 KB
  • 大小: 49.7 KB
分享到:
评论

相关推荐

    Perl-5.10.0版本

    Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0版本,Perl-5.10.0...

    strawberry-perl-5.32.1.1-64bit perl 解释器

    Perl是一种高级的、通用的、解释型、动态的编程语言,以其强大的文本处理能力和在系统管理领域的广泛应用而著名。"strawberry-perl-5.32.1.1-64bit" 是一个专为Windows平台设计的Perl解释器,它包含了Perl 5.32.1.1...

    草莓perl安装包下载

    草莓perl安装包下载,新版本 Strawberry Perl是用于MS Windows的perl环境,其中包含运行和开发perl应用程序所需的一切。 它被设计为尽可能接近UNIX系统上的perl环境。 它包括perl二进制文件,编译器(gcc)+相关...

    Perl语言编程.pdf

    Perl语言编程 Perl语言是一种高级的、通用的、脚本语言,它是由Larry Wall在1987年开发的。 Perl语言是一种功能强大、灵活的语言,应用非常广泛,包括文本处理、网络编程、数据库交互、系统管理员等。 Perl语言的...

    ​ActivePerl5.28版本下载、ActivePerl下载

    其包含了包括有 Perl for Win32、Perl for ISAPI、PerlScript、Perl Package Manager四套开发工具程序,可以让用户编写出适用于unix,windows,linux系统的CGI程序来。 CGI(Common Gateway Interface)公共网关...

    Perl语言学习.pdf

    Perl语言学习 Perl语言是由Larry Wall在20世纪80年代开发的一种开源的高级语言,它结合了低级语言和高级语言的特性,具有速度快、灵活性强和可读性好的特点。Perl语言的产生是为了解决awk语言无法生成报表的问题,...

    windows Strawberry Perl 5.32最新版本

    windows Strawberry Perl 5.32最新版本 ,适合调试 perl windows Strawberry Perl 5.32最新版本 ,适合调试 perl windows Strawberry Perl 5.32最新版本 ,适合调试 perl windows Strawberry Perl 5.32最新版本 ...

    Perl开发环境.zip

    "Perl开发环境.zip" 提供的是在Windows操作系统上搭建Perl开发环境的资源,具体是"strawberry-perl-5.32.0.1-64bit.msi" 文件,这是一个64位的Perl解释器安装程序。 Strawberry Perl 是Perl在Windows上的一个受欢迎...

    perl TK 编程指南 (perl_tk_tutorial)

    ### Perl TK 编程指南知识点概述 #### 一、引言 Perl/Tk(也称为pTk)是一种结合了易于配置的Tk8组件工具包与Perl5强大的词法解析、动态内存管理及面向对象能力的模块集合。简而言之,它是一种用于创建带有图形用户...

    perl脚本perl脚本perl脚本

    perl脚本perl脚本perl脚本perl脚本

    Perl程序如何调用C代码

    ### Perl程序如何调用C代码 #### 概述 在软件开发领域,有时我们需要结合不同编程语言的优势来解决复杂的问题。Perl 和 C 是两种广泛使用的编程语言,它们各自具有独特的特性和应用场景。Perl 以其强大的文本处理...

    perl 离线安装rpm包

    在Linux环境中,Perl是一种强大的脚本编程语言,广泛用于系统管理、网络编程、文本处理以及各种自动化任务。在离线安装场景中,Perl RPM包对于那些没有互联网连接或者需要在安全环境中部署软件的用户尤其重要。本文...

    ActivePerl_5.16

    ActivePerl是Perl编程语言的一个流行的Windows版本,由ActiveState公司提供。标题中的"ActivePerl_5.16"指的是该软件的特定版本,即5.16系列。Perl是一种强大的文本处理和脚本编程语言,广泛应用于系统管理、网络...

    perl-5.28.zip

    Perl是一种强大的、高级的、通用的脚本编程语言,它在1987年由Larry Wall设计并首次发布。Perl 5.28是这个语言的一个重要版本,它提供了许多改进和新特性,以满足现代编程需求。这个压缩包“perl-5.28.zip”包含了...

    64位strawberryperl的5.32安装包

    Perl是一种强大的、跨平台的脚本编程语言,广泛应用于系统管理、网络编程、网页开发以及生物信息学等领域。在Windows操作系统上,Perl的使用通常分为两种主要的方式:ActiveState Perl和Strawberry Perl。 ...

    perl(windows环境)

    Perl是一种强大的、跨平台的脚本编程语言,尤其在文本处理和系统管理任务中广泛应用。在Windows环境下,Perl同样能够提供高效和灵活的编程能力。标题提到的"perl(windows环境)"表明我们将讨论如何在Windows操作系统...

    perl常见编程100个实例

    Perl是一种强大的脚本编程语言,尤其在文本处理和系统管理任务方面表现突出。"perl常见编程100个实例"提供了丰富的示例,帮助初学者和有经验的开发者更好地理解和运用Perl语言。这些实例覆盖了Perl编程的多个关键...

    strawberry-perl-5.10.1.0

    Strawberry Perl是Windows平台上的一种Perl解释器的发行版,它提供了完整的Perl开发环境,包括Perl语言本身、标准库以及许多常用的CPAN(Comprehensive Perl Archive Network)模块。这个版本号5.10.1.0表明它是基于...

    strawberry-perl-5.32.1.1-64bit

    Strawberry Perl是Perl语言在Windows操作系统上的一个流行的开源实现,尤其受到开发者和系统管理员的欢迎。这个"strawberry-perl-5.32.1.1-64bit"压缩包是针对64位系统的,这意味着它设计用于运行在64位版本的...

    linux 离线安装perl-IPC-Cmd

    在Linux环境中,Perl是一种强大的脚本编程语言,广泛用于系统管理、网络编程和文本处理等任务。`IPC::Cmd`是Perl的一个模块,它提供了一种简单且灵活的方式来执行外部命令并获取其输出。在没有互联网连接的情况下,...

Global site tag (gtag.js) - Google Analytics