我想将fifo管道中的数据插入到mysql表中
我的脚本如下:
#!/usr/bin/perl
#Script to read data out of a named pipe and write to MySQL database.
$| = 1;
use strict;
use DBI();
my $filename;
my $inputline;
my $linenumber;
my @arr;
$filename = "./SEC_fifo";
open(FIFO, "+< $filename") or die "FIFO error on $filename $!";
my $dbh = DBI->connect("DBI:mysql:database=ecdb;host=localhost",
"user", "[pwd]",
{'RaiseError' => 1});
while (<FIFO>)
{
$inputline = $_;
@arr = split(/,/,$inputline);
# Quit read loop when requested.
last if($inputline =~ /quit/i);
chop $inputline;
$linenumber++;
print "Got: [$inputline], "; …Run Code Online (Sandbox Code Playgroud) 我想得到系统时钟(时间和日期)并在Perl中以人类可读的格式显示它.格式如2014-09-12 15:13:56
#!/usr/local/bin/perl
my %months = qw(Jan Feb Mar Apr May Jun Jul
Aug Sep Oct Nov Dec);
@weekDays = qw(Sun Mon Tue Wed Thu Fri Sat Sun);
($second, $minute, $hour, $dayOfMonth, $month, $yearOffset, $dayOfWeek, $dayOfYear,
$daylightSavings) = localtime();
$year = 1900 + $yearOffset;
$now = "$year-$months-$dayOfMonth $hour:$minute:$second";
print $now;
Run Code Online (Sandbox Code Playgroud)
当您运行该程序时,您应该看到更加可读的日期和时间,如下所示:
2014--12 16:57:15
Run Code Online (Sandbox Code Playgroud)
如何将月份转换为数字?
在Perl 5.26.1中,我得到:
Experimental each on scalar is now forbidden at a.plx line 67.
Type of arg 1 to each must be hash or array (not private variable) at a.plx
line 67, near "$val)"
Execution of a.plx aborted due to compilation errors.
Run Code Online (Sandbox Code Playgroud)
第67行是其中的
67 while (my ($ip, $val2) = each($val))
68 {
......
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试检测屏幕分辨率,然后设置位置(如顶部,左侧)以获得多个屏幕分辨率,但它无法正常工作.谁知道我的代码有什么问题?
CSS:
.Scrolloutside
{
position:relative;
left: 550px;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript的:
var nHeight = screen.height;
var nWidth = screen.width;
if (nHeight ==714 && nWidth==1005)
{
//document.write("height:"+nHeight+" ,width="+nWidth+"<br>");
var newsTarget = document.getElementsByClassName('Scrolloutside');
newsTarget.style.top= "500px";
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class = "Scrolloutside">
<div class="scroller_title">News</div>
<div class="scroller_container">
<div class="jscroller2_up">
<?
echo $secnews;
?>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我想得到当地时间并格式化为YYYY-mm-dd HH:MM:SS(比如2009-11-29 14:28:29).,我怎样才能得到这种格式的日期YYYY-mm-dd HH:MM :SS?
我试过了
my $format = "%4u-%02u-%02u %02u:%02u:%02u";
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
printf "$format\n", $year+1900, $mon+1, $mday, $hour, $min, $sec;
Run Code Online (Sandbox Code Playgroud)
打印输出是我想要的,但如何设计输出到变量?
我有这个字符串
24.733835, 121.34365500000001:AP-54184
Run Code Online (Sandbox Code Playgroud)
我想用':'溢出字符串,但为什么不能溢出字符串
var newarray= '24.733835, 121.34365500000001:AP-54184'.spilt(/:/);
document.write(newarray[0]+","+newarray[1]+"<br>");
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题吗?