luogen33的博客
luogen33 · 共 48 篇文章
perl将十进制转换为64进制的方法
#!/usr/bin/perl 将十进制转换为64进制的方法 $arr="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ+/"; sub ch_num_to_64(){ #参数 my @list_data=(); my $res_data; my $res =$_; if (int($res)==0){ $res_data=0; } my $res2; while($res != 0) { $res2 = $res%64; push(@list_data,substr($arr,$res2,1)); $res = …
2011-11-25 14:09 · 评论(1)
perl 正则表达式
正则表达式: $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…
2011-11-25 14:04 · 评论(0)
javascript add node
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
2011-10-20 00:09 · 评论(0)
perl 文本文件入库
#!/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 "Can't connect: " . DBI->errstr; my $sth=$dbh->prepare("insert into …
2011-09-27 00:22 · 评论(2)
perl与mysql
一、简介 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包用于处理与Or…
2011-09-27 00:20 · 评论(0)
perl操作oracle数据库
到: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 tar zxvf DBI-1.613.tar.gz cd DBI-1.613 perl Makefile.PL #make #make install #cd tar zxvf DBD-Oracle-1.21.tar.gz cd DBD-Oracle-1.21 在oracle的HOME目录下的.bash_…
2011-09-26 23:31 · 评论(0)
perl操作mysql数据库
#!/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 "Can't connect: " . DBI->errstr; # 操作多列 my $sth=$dbh->prepare("se…
2011-09-26 23:06 · 评论(2)
perl中获取某个域名的全部ip
#!/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 $_, "\t"; }
2011-09-26 22:26 · 评论(0)
perl中获取浮动ip
通过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, SIOCGIFADDR(), $pack); re…
2011-09-26 22:20 · 评论(0)
perl中去掉字符串中空格
Perl code use strict; use warnings; my $str=" \n aaa bbb\n "; $str=~s/^\s+|\s+$//g; print($str); ^D aaa bbb
2011-09-26 22:02 · 评论(0)
get the max num in bash language
#!/bin/bash #get the max num echo; echo "------test get the max num of two nums----- "; EQUAL=0; E_PARAM_ERR=-9999; max2() { if then echo $E_PARAM_ERR; return; fi if then echo $EQUAL; return; else if then ret=$1; else ret=$2; fi fi #can't use the return sentence,in here . #because the method can re…
2011-09-06 23:36 · 评论(0)