在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 2828|回复: 1

Perl试题集

[复制链接]
发表于 2012-4-6 20:03:12 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
用perl实现9*9乘法口诀,以下是本人的perl程序#!/usr/bin/perl
use strict;
use warnings;
my $i;
my $j;
for ($i=1;$i<=9;$i++){
print "$i\n";
for ($j=1;$j<=9;$j++){
my multi=$i*$j;
print $result;
}
}
如有不妥之处,或者更好的代码,欢迎大家共享哈~
 楼主| 发表于 2012-4-6 21:20:25 | 显示全部楼层
回复 1# daiyijun


   合并两个文件夹中的内容至一个文件夹#!/usr/bin/perl
use strict;
use warnings;

open a,"a.txt" or die "cannot open the file $!";
open b,"b.txt" or die "cannot open the file $!";
open c,"c.txt" or die "cannot open the file $!";
my @b_1;
while(<b>){
push @b_1, $_;
}
my @a_1;
my $line;
while ($line=<a>){
$line=~/\n/ /g;
push @a_1,$line;
}
my $len;
$len=@a_1>@b_1?@a_1b_1;
for(my $i=0;$i<$len;$i++){
if (defined $a_1[$i] && defined $b_1[$i]){
$a_1[$i]=$a_1[$i].$b_1[$i];
}
}
print c @a_1;
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-6-23 22:44 , Processed in 0.015787 second(s), 10 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表