是否可以在数据库中保存一些Perl代码然后使用select语句检索它然后执行该Perl代码?我尝试过使用eval,但这似乎不起作用.
这是我现在正在尝试的东西,它似乎不起作用:
my $temp = $qryResults[0];
print $temp."\n";
eval{"$temp"};
Run Code Online (Sandbox Code Playgroud)
输出是 $con->Disconnect();exit;
我正在寻找一种从网页上抓取URL并将其输出到文本文件的方法.例如,如果一个页面包含多个http://example.com/article 我想抓住这两个网址,并输出到一个文本文件中.
嗨,我刚刚IF在我的源中添加了一个条件,从那时起我就收到了错误
"
_HTML_在EOF之前的任何地方找不到字符串终结符"
但如果我删除它,它的工作原理 IF
我是Perl和CGI的新手,我不知道如何解决这个错误.
这是我的代码:
#!"\xampp\perl\bin\perl.exe"
use CGI qw/:standard/;
use CGI::Cookie;
%cookies = CGI::Cookie->fetch;
$Cookie = $cookies{'USER'}->value;
if ($Cookie)
{
print "Content-type: text/html\n\n";
print<<_HTML_;
<!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6 lt8"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7 lt8"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8 lt8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head> …Run Code Online (Sandbox Code Playgroud) 我在Windows 7上使用ActivePerl-5.18.4.1804.我有一个需要XML :: RSS模块的脚本.我确实使用它安装它ppm,但我总是有相同的错误消息:
Can't locate XML/RSS.pm in @INC (@INC contains: /usr/lib/perl5/site_perl/5.14/i686-cygwin-threads-64int /usr/lib/perl5/site_perl/5.14 /usr/lib/perl5/vendor_perl/5.14/i686-cygwin-threads-64int /usr/lib/perl5/vendor_perl/5.14 /usr/lib/perl5/5.14/i686-cygwin-threads-64int /usr/lib/perl5/5.14 /usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10 /usr/lib/perl5/site_perl/5.8 .) at bao1.pl line 3. BEGIN failed--compilation aborted at bao1.pl line 3.
||Perl 的作品如何?我想实现c风格的||操作.
@ARRAY=qw(one two THREE four);
$i=0;
if(($ARRAY[2] ne "three")||($ARRAY[2] ne "THREE")) #What's the problem with this
{
print ":::::$ARRAY[2]::::::\n";
}
while(($ARRAY[$i] ne "three")||($ARRAY[$i] ne "THREE")) #This goes to infinite loop
{
print "->$ARRAY[$i]\n";
$i=$i+1;
}
Run Code Online (Sandbox Code Playgroud) 我有一个包含几个元素的数组:
MSN = 34.3433423432434%
Chrome = 12.4343434353534%
Gtalk = 32.23233543543532%...
我将这个数组作为y轴标签传递给一个名为GD :: Graph的模块.我现在面临的问题是,图表上的数字是如此之大,以至于它们与相邻条目重叠并使其无法读取.
有没有办法可以将数组中的所有元素四舍五入到小数点后两位?并使它xx.xx%?
此外,任何熟悉使用GD :: Graph的人,您知道如何增加图表上的文字大小吗?我可以很好地增加标题/图例大小,但是'Gtalk'或'32 .23233543543532%'中的实际文本非常小,我已经尝试了很多来自http://search.cpan.org/dist/GDGraph的命令/Graph.pm,但它们似乎对我不起作用!
我正在接收某个流程的输出(如下@result_listosp所示).当我尝试chomp输出很奇怪.我希望以下输出:
origin-server-pool-1 http_TestABC https_TestABC
Run Code Online (Sandbox Code Playgroud)
码:
use strict;
use warnings;
my @result_listosp = ( # From backticks
"origin-server-pool-1\n",
"http_TestABC \n",
"https_TestABC\n",
);
chomp @result_listosp;
Run Code Online (Sandbox Code Playgroud)
输出:
origin-server-pool-1http_TestABC https_TestABC
Run Code Online (Sandbox Code Playgroud) 我有一个脚本作为输入两个文件:
我必须将提取与源进行比较:提取的每一行都应该在源中.如果没有,我必须记录一行日志文件.
脚本下方:
#!/perl/bin/perl
use strict;
use warnings;
use feature 'say';
# Open log file
open(LOG, '>', 'log.txt');
# Start log
say LOG '['.localtime().'] Début execution';
# Declare extraction number of line counter
my $i_extraction_counter = 1;
# Define files to be compared (extraction against source)
my ($extraction_file, $source_file) = @ARGV;
# Open extraction file
open my $f_extraction, "<", $extraction_file;
# Store extraction file in a hash
my %h_extraction;
while(defined(my $extr_line = <$f_extraction>)){
$h_extraction{$extr_line} = $extr_line;
$i_extraction_counter++;
} …Run Code Online (Sandbox Code Playgroud) 当我运行以下Perl单线程时:
$ perl -e 'print "Oh no!\n" unless 1835 == 100*18.35'
Run Code Online (Sandbox Code Playgroud)
我明白了
Oh no!
这是为什么?