Perl学习之例程(子程序)(1 位领导批示)

例程 Subroutine 类似vbscript 中的子例程..在perl里也叫做函数(function),是结构化程序设计的基础。它接受多个输入参数,返回一个输出参数。

之所以说类似vbscript,就是定义时的语法几乎完全一样


sub subroutine_name(){...}

一个简单的例子:


use strict;#严格声明..加了这个之后使用变量之前必须声明.如:my $fs;
use warnings;
use Win32::OLE; #加载WIN32::OLE模块

sub getPath($)
{
my $wawa = shift;#shift是用来替换传递的例程参数
my $fs = Win32::OLE->new("Scripting.FileSystemObject");
my $folder = $fs->GetFolder(".");
my $ls_path = $folder->path;
return $wawa.$ls_path;
}

my $path = getPath('当前路径:');

print $path;

打印出当前文件所在的绝对路径..

Win32::OLE 是perl中实现对OLE对象的支持的模块.

Input file 文件选择框美化 支持Firefox(0 位领导批示)

闲来无事写了一个.也许用得上

在FF2,IE7,IE6下测试通过

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="wuleying" />
<!--<script type="text/javascript" src="ajax.js"></script>-->
<title>测试上传文件</title>
<style type="text/css">
* {font-size:12px;margin:0;}
body {background:#fff;}
form {margin:12px;}
input.file{
	vertical-align:middle;
	position:relative;
	left:68px;
	*left:-218px;
	filter:alpha(opacity=0);
	opacity:0;
	z-index:1;
	*width:223px;
	display:none;
}
form input.viewfile {
	z-index:99;
	border:1px solid #ccc;
	padding:2px;
	width:150px;
	vertical-align:middle;
	color:#999;
}
form p span {
	float:left;
}
form label.bottom {
	border:1px solid #38597a;
	background:#4e7ba9;
	color:#fff;
	height:19px;
	line-height:19px;
	display:block;
	width:60px;
	text-align:center;
	cursor:pointer;
	float:left;
	position:relative;
	*top:1px;
}
form input.submit {
	border:0;
	background:#380;
	width:70px;
	height:22px;
	line-height:22px;
	color:#fff;
	cursor:pointer;
}
p.clear {
	clear:left;
	margin-top:12px;
}
p.filep {
	height:25px;
}
p.clear input {
	float:left;
	margin-right:6px;
}
#error {
	padding-top:5px;
	color:#f00;
}
</style>
</head>
<body>
<form action="" onsubmit="return send();" method="post" name="upfiles" enctype="multipart/form-data"><br />
<input type="hidden" name="max_file_size" value="2097152" />
<input type="hidden" name="do" value="upload" />
<p class="filep">
	<span>
		<label for="viewfile">上传文件:</label>
		<input type="text" onmouseout="document.getElementById('upload').style.display='none';" name="viewfile" id="viewfile" class="viewfile" />
	</span>
	<label for="upload" class="bottom" onmouseover="document.getElementById('upload').style.display='block';">查找文件</label><input type="file" id="upload" size="27" name="upload[]" onchange="document.getElementById('viewfile').value=this.value;this.style.display='none';" class="file" />
</p>
<p class="clear"><input class="submit" type="submit" value="确定上传" /><div id="error"></div></p>
</form>
</body>
</html>

有趣的Perl(0 位领导批示)

最近修改一个站点.用Perl语言写的..

从没碰过..有点犯晕.不过PHP最早就是Perl的一个扩展.语法上十分类似.
就硬着头皮上了.

一打开pl文件就犯了眼晕..
光变量前缀就有三种.

$还是很熟悉的嘛..但在Perl里却只能做为标量变量的前缀

还有一个@与%,分别是数组与哈希数组的前缀

老把@当做抑错符.PHP的习惯还是改不了..

继续学习中…

另:查到Perl的两个全称

Practical Extractoin and Report Language 实用抽取和报表语言

Pathologically Electric Rubbish Lister 变态电子垃圾制造者 (哈哈)

Tags : ,

用 Fast Folder & Command 快速访问常用的文件夹(0 位领导批示)

Fast Folder & Command 是一款超强的外壳增强软件。它可以让您快速访问常用的文件夹。
你只需要在桌面或资源管理器空白处单击鼠标右键就可以在其中找到“快捷文件夹”菜单。通过该菜单你可以快速访问已定义的文件夹进行快捷文件夹编辑或添加操作。

Fast Folder & Command 还可以为您创建快捷命令。快捷命令可以为您启动程序、打开文件夹、运行文件或者启动 URL。你只需要在程序中配置快捷命令的别名与路径,然后打开开始菜单中的运行对话框,输入先前配置程序的别名即可!十分方便!

软件界面:

LOOK:
view.gif

下载地址:http://www.onlinedown.net/soft/49673.htm

(备忘)MySQL实用命令(0 位领导批示)

一 连接MYSQL:

格式: mysql -h主机地址 -u用户名 -p用户密码

1、例1:连接到本机上的MYSQL

首先在打开DOS窗口,然后进入mysql安装目录下的bin目录下,例如: D:\mysql\bin,再键入命令mysql -uroot -p,回车后提示你输密码,如果刚安装好MYSQL,超级用户root是没有密码的,故直接回车即可进入到MYSQL中了,MYSQL的提示符是:mysql>

2、例2:连接到远程主机上的MYSQL

假设远程主机的IP为:10.0.0.1,用户名为root,密码为123。则键入以下命令:
mysql -h10.0.0.1 -uroot -p123
(注:u与root可以不用加空格,其它也一样)

3、退出MYSQL命令

exit (回车)

全文阅读 »

date函数格式化UNIX时间戳时差问题的解决方法(2 位领导批示)

插入数据库里的时间格式是unix时间戳

当再用date函数格式化unix时间戳时发现是格林尼治的时间


$nowtime = time();
$mtime = date('Y-m-d H:i:s',$nowtime);

echo $mtime;

解决方法:

在使用date函数之前先设置默认时区


date_default_timezone_set('Etc/GMT-8');

OK..现在输出的就是东八区的时间了..

上传图片附件显示缩略图(3 位领导批示)

刚开始以为很容易解决.写js嘛..-_,-+


< i nput type="file" onchange="document.getElementById('showimg').src=this.value;" />

然而本地测试成功的代码上传到服务器上就出现了错误..空格被自动转义成为了%20

无语ing….囧..

不过总算找到一个BT的方法..用CSS中的AlphaImageLoader滤镜 -_!!

AlphaImageLoader滤镜的使用方法就不做说明..自己查下手册

AlphaImageLoader滤镜的src属就是其中的主角 它将使用绝对或相对url地址指定背景图像。假如忽略此参数,滤镜将不会作用。

放出代码

全文阅读 »

超二批处理,原来只有三行(0 位领导批示)

1.关闭apache. 后面是apache的版本号.俺这里用的是2.2
2.删除apache错误日志防止错误日志过多,del /q 后是错误日志的绝对路径
3.重新启动apache


net stop apache2.2
del /q D:\apache\logs\error.log
net start apache2.2

存成bat文件.需要重启apache双击便可

简单但提高了效率..

清除系统垃圾文件(3 位领导批示)

系统运行一段时间就会产生很多无用的临时文件.

一个批处理.快速清除系统垃圾文件


@echo off
echo 清除系统垃圾启动,请稍等......
del /f /s /q %systemdrive%\*.tmp
del /f /s /q %systemdrive%\*._mp
del /f /s /q %systemdrive%\*.log
del /f /s /q %systemdrive%\*.gid
del /f /s /q %systemdrive%\*.chk
del /f /s /q %systemdrive%\*.old
del /f /s /q %systemdrive%\recycled\*.*
del /f /s /q %windir%\*.bak
del /f /s /q %windir%\prefetch\*.*
rd /s /q %windir%\temp & md %windir%\temp
del /f /q %userprofile%\cookies\*.*
del /f /q %userprofile%\recent\*.*
del /f /s /q "%userprofile%\Local Settings\Temporary Internet Files\*.*"
del /f /s /q "%userprofile%\Local Settings\Temp\*.*"
del /f /s /q "%userprofile%\recent\*.*"
echo 清除系统垃圾完毕!按任意键退出!
echo. & pause

复制上面代码.保存在文本文档中.改扩展名为.bat  双击运行.
或是在命令行里直接运行

Love China - MSN(2 位领导批示)

发篇与技术无关的日志.

昨天接到朋友的消自.在MSN的呢称前加上(L)CHINA.据统计目前已有230万人用上了这个呢称前缀.这一数字还在不断增长.

支持爱国行动.而不是非理性的抵制.中国人应该更有自信.

love china

Tags : , ,

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志