- 浏览: 83282 次
- 性别:
- 来自: 南京
-
文章列表
#!/usr/bin/perl
# 将十进制转换为64进制的方法
$arr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/";
sub ch_num_to_64(){
#参数
my @list_data=();
my $res_data;
my $res =$_[0];
if (int($res)==0){
$res_data=0;
}
my $res2;
while($res != 0)
{
$res2 = $res%64;
push(@l ...
正则表达式:
$scalarName =~ s/a/b; # substitute the character a for b, and return true if this can happern
$scalarName =~ m/a; # does the scalar $scalarName have an a in it?
$scalarName =~ tr/A-Z/a-z/; # translate all capital letter with lower case ones, and return ture
if this happens
$scalarName !~ s/a/b ...
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<Script Language="Javascript">
var cGetRow=-99999;
var i=0;
function
AddRow() {
//添加一行
var newTr = tab1.insertRow(0);
//添加两列
var newTd0 = newTr.insertCell(0);
var newTd ...
#!/usr/bin/perl
use DBI;
my $driver="DBI:mysql";
my $database="test";
my $user="root";
my $host="localhost";
my $passwd="luogen30";
my $dbh = DBI->connect("$driver:database=$database;host=$host;user=$user;password=$passwd")
or die &qu ...
一、简介
PERL应用数据库由两种方法,其一是利用本身所配置的DBM包,这个可以建立数据库并对其进行操作,因此可以把DBM包以及其他类似的包看作是一个数据库的扩展。另一个就是利用DBI包或者类似的包建立与其他关系型数据库的连接,显然,我们通常需要利用后者。
数据库接口(DBI)是由TIM BUNCE(Tim.Bunce@ig.co.uk)所书写,DBI是专门为PERL所书写。你可以在
http://www.hermetica.com/technologia/DBI/ 查找到相应的信息。
最初,DBI只是由Tim Bunce开发的一个接口包,后来,他开发了DBD::Oracle包用于处理与O ...
到:http://search.cpan.org/~timb/DBI-1.613/lib/DBI/DBD/SqlEngine.pm
下载DBI-1.6
和到:http://search.cpan.org/~pythian/DBD-Oracle-1.21/
下载DBD-Oracle-1.21
[root@localhost ~]# tar zxvf DBI-1.613.tar.gz
[root@localhost ~]# cd DBI-1.613
[root@localhost DBI-1.613]# perl Makefile.PL
[root@localhost DBI-1.613]#mak ...
#!/usr/bin/perl -w
use DBI;
my $driver="DBI:mysql";
my $database="test";
my $user="root";
my $host="localhost";
my $passwd="luogen30";
my $dbh = DBI->connect("$driver:database=$database;host=$host;user=$user;password=$passwd")
or die ...
#!/usr/bin/perl
my @dns=`nslookup www.baidu.com `;
@ip;
@iptable;
for(2..$#dns)
{
$row = $dns[$_];
if($row =~ /\d+/)
{
$row =~ /(\d+\.\d+\.\d+\.\d+)/;
push @ip, $1;
}
}
foreach (@ip)
{
/\d+\.\d+\.(\d+)\.\d+/;
push @iptable, $1;
}
print @dns;
print "\n";
foreach(@iptable)
{
print $ ...
通过strace ifconfig命令可以看到,linux实质是通过ioctl命令完成的网络接口ip获取。那么,我们也用ioctl就是了!
如下:
#!/usr/bin/perl
use strict;
use warnings;
use Socket;
require 'sys/ioctl.ph';
sub get_ip_address($) {
my $pack = pack("a*", shift);
my $socket;
socket($socket, AF_INET, SOCK_DGRAM, 0);
ioctl($socket, ...
Perl code
use strict;
use warnings;
my $str=" \n aaa bbb\n ";
$str=~s/^\s+|\s+$//g;
print($str);
^D
aaa bbb
#!/bin/bash
#get the max num
echo;
echo "------test get the max num of two nums----- ";
EQUAL=0;
E_PARAM_ERR=-9999;
max2()
{
if [ -z "$2" ]
then
echo $E_PARAM_ERR;
return;
fi
if [ $1 -eq $2 ]
then
echo $EQUAL;
return;
else
if [ $1 -gt $2 ]
then
ret=$1;
else
r ...