小编tjd*_*tjd的帖子

JSF渲染了多个组合条件

我需要给出条件

 if((a == 12 and b == 13) or(a == 12 and b == 15))
Run Code Online (Sandbox Code Playgroud)

在JSF渲染属性中.

有人可以帮忙吗?

jsf rendered-attribute

30
推荐指数
1
解决办法
10万
查看次数

Perl从随机填充的数组计算平均值

我有一份我需要帮助的学校作业.现在,我知道你在想什么,但我的老师不在城里,也没有回复我的电子邮件,我的其他同学也不知道如何解决这个问题.一些指示和提示将不胜感激!

作业是这样的:

我们应该创建一个数组,用1-100的20到30个随机整数填充它.然后,在子程序的帮助下,我们应该计算这些数字的平均值.

当我调用子程序时会出现问题,这给了我0或"非法除0"错误.我现在的代码是这样的:

#! /usr/bin/perl -w

use warnings;
use strict;

# Declaring the scalar variables and arrays.
my @AllNumbers;

# Create random data set of between 20 to 30 measures used for the 100 random intigers.
my $random_number = int( rand( 31 - 20 ) ) + 20;

# Create random data set of 100 intigers.
for ( my $i = 0 ; $i <= $random_number ; $i++ ) {
    $AllNumbers[$i] = int( rand( 100 - 1 ) ); …
Run Code Online (Sandbox Code Playgroud)

arrays perl

10
推荐指数
3
解决办法
1710
查看次数

在正则表达式中使用.{1}感到困惑

在最近关于Stack Overflow的几个问题中,我看到了正则表达式序列.{1}.在我熟悉的正则表达式引擎中,重复计数为1是严格多余的.

有没有我不知道的正则表达式引擎,这不是真的吗?

这个显式计数1是否可以尝试评论/突出显示前面.的元字符?

我只是想了解这种做法的动机.


友情链接:带有$ anchor的正则表达并向前看是最新的...寻找其他...

regex

9
推荐指数
1
解决办法
100
查看次数

Perl警告:在连接或字符串中使用未初始化的值

我越来越:

"Use of uninitialized value in join or string at ./test_script.pl line 69, <fh> line 91."
Run Code Online (Sandbox Code Playgroud)

创建此警告的代码如下:

# Write results of SQL execution to output file
if ($@) { print "\n DB Error : ", $@; exit; }
open(FH, ">$output_file") or 
        die "\n cannot write to the file $output_file. Check the file permissions";
while(my @row= $sth->fetchrow_array) {
      print FH join($delimiter, @row). "\n";
}
Run Code Online (Sandbox Code Playgroud)

它来自"while"块中的"print ... join ...."行,但我不确定100%是由什么引起它以及如何纠正它.

$ delimiter先前初始化$ delimiter ="|" 并且@row从前一行的$ sth操作中获取其值.

这是关于@row值的"时间"问题还是正在处理的实际SQL查询文件中的某些内容,如警告的"<fh>第91行"部分所示?关于如何避免警告的任何想法?顺便说一下,脚本工作正常,它只是为每个获取的@row值生成一个警告,这会在大数据集拉动时产生大量警告......

perl warnings dbi

6
推荐指数
1
解决办法
1万
查看次数

Perl并行运行两个while循环子例程

我希望并行运行两个子程序,其中两个子程序使用ADB命令在Android手机上执行相同的任务.在SO和其他研究的帮助下,我在下面编写了以下代码,但是我是多线程新手,在执行过程中出现了"Free to wrong pool"错误.我假设我得到这个,因为我在两个线程中使用$ _变量,这是正确的吗?我使用Windows7来运行它,但我的Perl解释器在运行此脚本时崩溃.任何指导将不胜感激.谢谢.

use strict;
use Win32::OLE;
use EFS_Handle;
use HelperFunctions;
use threads;

#### Various ADB command sequences follow ####
#### Start of multithread to run the same function on different android handsets ####

my @jobs;

push @jobs, threads->create(
    sub {
        print "\n\t" . curTime() . " :\t DUT Time at start of MPLMN search";

        open my $fh1, '>', "output.txt" or die "Cannot open output.txt: $!";
        my $pid1 = open my $log1, "-|", "adb -s 42d8d7dd logcat";

        system('adb …
Run Code Online (Sandbox Code Playgroud)

perl multithreading

5
推荐指数
1
解决办法
1135
查看次数

Perl模块错误 - 已弃用定义的(%哈希)

背景:

  • 我正在努力将Linux服务器迁移到Ubuntu 10.04到12.04的新服务器
  • 该服务器负责通过crontabs执行多个Perl模块.
  • 这些Perl模块严重依赖30-40 perl扩展.
  • 我已经安装了所有Perl扩展,并且crontabs能够成功处理,除了由这些Perl扩展的较新版本引起的几个语法错误.
  • 我需要一些帮助来修改语法以使Perl脚本按预期进行处理.

错误:

defined(%hash) is deprecated at pm/Alerts/Alerts.pm line 943.
        (Maybe you should just omit the defined()?)
defined(%hash) is deprecated at pm/Alerts/Alerts.pm line 944.
        (Maybe you should just omit the defined()?)
Run Code Online (Sandbox Code Playgroud)

码:

###
    # Iterate the arrays deleting identical counts from each.
    # If we found a mismatch then die.
    # If either array is not empty when we are done then die
    $logger->info('Comparing ' . (scalar keys %cms_rows) . ' CMS symbols to …
Run Code Online (Sandbox Code Playgroud)

linux perl hash perl-module crontab

5
推荐指数
1
解决办法
4961
查看次数