perl 怎么调用子程序里的变量
时间:2010-09-06
来源:互联网
#!/usr/bin/perl -w
use strict;
our $WORK_DIR = $ARGV[0] . '/test';
our $SAVE_DIR = $ARGV[0] . '/saved';
&ReadDir($WORK_DIR);
if ( -d $SAVE_DIR/$part_path)
{
print $SAVE_DIR/$part_path;
}
else
{
print "hehe";
}
sub ReadDir
{
my ($dir) = @_;
opendir(DIR, $dir);
print $dir,"\n";
foreach my $element (readdir(DIR))
{
my $full_path = "$dir/$element";
if ('.' eq $element || '..' eq $element) { next; }
print $full_path,"\n";
print "1111111","\n";
if (-d $full_path)
{
print "directory".$full_path,"\n";
&ReadDir($full_path);
}
else
{
print "not directory","\n";
print "full_path=",$full_path,"\n";
my $partical_path = substr($full_path,29);
print "partical_path=",$partical_path,"\n";
our $part_path = substr($partical_path,0,rindex($partical_path,'/')+1);
print "part_path=",$part_path,"\n";
my $txtfile_dir = substr($full_path,0,rindex($full_path,'/')+1);
print $txtfile_dir,"\n";
my $call_unix = "cp $txtfile_dir/*.txt /ouc/oucdev/adm/ftp/cws/test2/";
system($call_unix);
}
}
closedir(DIR);
}
use strict;
our $WORK_DIR = $ARGV[0] . '/test';
our $SAVE_DIR = $ARGV[0] . '/saved';
&ReadDir($WORK_DIR);
if ( -d $SAVE_DIR/$part_path)
{
print $SAVE_DIR/$part_path;
}
else
{
print "hehe";
}
sub ReadDir
{
my ($dir) = @_;
opendir(DIR, $dir);
print $dir,"\n";
foreach my $element (readdir(DIR))
{
my $full_path = "$dir/$element";
if ('.' eq $element || '..' eq $element) { next; }
print $full_path,"\n";
print "1111111","\n";
if (-d $full_path)
{
print "directory".$full_path,"\n";
&ReadDir($full_path);
}
else
{
print "not directory","\n";
print "full_path=",$full_path,"\n";
my $partical_path = substr($full_path,29);
print "partical_path=",$partical_path,"\n";
our $part_path = substr($partical_path,0,rindex($partical_path,'/')+1);
print "part_path=",$part_path,"\n";
my $txtfile_dir = substr($full_path,0,rindex($full_path,'/')+1);
print $txtfile_dir,"\n";
my $call_unix = "cp $txtfile_dir/*.txt /ouc/oucdev/adm/ftp/cws/test2/";
system($call_unix);
}
}
closedir(DIR);
}
作者: zjm6533637 发布时间: 2010-09-06
回复 zjm6533637
你的问题是啥!
你的问题是啥!
作者: Perl_Er 发布时间: 2010-09-06
你想问什么?
作者: wfnh 发布时间: 2010-09-06
错了 我想问的是
我调用子程序
怎么表示传进去的参数啊???
我调用子程序
怎么表示传进去的参数啊???
作者: zjm6533637 发布时间: 2010-09-06
就是怎么表示 第一个参数 第二个参数 第三个参数
作者: zjm6533637 发布时间: 2010-09-06
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28