小编Seb*_*olm的帖子

Perl脚本不会运行; 只在浏览器中显示实际代码

我是Perl的新手,无法让我的脚本正常运行.我应该把实际的Perl脚本放在哪里才能正常运行?我正在测试我的笔记本上的所有内容,并尝试从html页面调用脚本,我得到的是我的Web浏览器中显示的实际脚本(代码)本身,而不是代码旨在生成的信息.因此,我想我应该将Perl文件放在其他地方?目前我在同一目录中有Perl脚本和HTML文件.任何帮助将不胜感激!见下文:

 <head>
   <title>Student Web Page</title>
 </head>

 <body>

  <h1>WELCOME! You have reached Kito's Student Web Page</h1>
  <br />
  <p>To run the folloiwing applications, click on the appropriate line:</p>

  <form ACTION="first.pl" METHOD="get">
    <p>
    <input TYPE="submit" VALUE="Step 5 - Perl Environment Variables">
    </p>
  </form>             
Run Code Online (Sandbox Code Playgroud)
#!c:\perl\bin\perl.exe -w
use strict;

print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Environment Variables</TITLE></HEAD><BODY>";

foreach (keys %ENV) {
    print "<BR><FONT COLOR=green>$_</FONT> is set to <FONT COLOR=red>$ENV{$_}</FONT>";
}

print "</BODY></HTML>";  
Run Code Online (Sandbox Code Playgroud)

html perl

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

始终隐藏虚拟键盘

实际上我有一个编辑文本.当我点击编辑文本虚拟键盘popups.But我只想隐藏虚拟键盘,即使点击编辑文本后.编辑文本应该可以打印系统键盘.我怎么能这样做?我的代码..

EditText edtNote = (EditText)findViewById(R.id.note);
InputMethodManager imm = (InputMethodManager) this.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.restartInput(edtNote);

Configuration config = this.getResources().getConfiguration();

if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
}
Run Code Online (Sandbox Code Playgroud)

android android-softkeyboard

2
推荐指数
1
解决办法
1498
查看次数

PHP mktime()适用于1900年前的日期

所以我正在研究这个按日期排序日期的系统.我正在使用制作时间,我一切正常,直到它击中1900年或以下.一切都返回12月24,1644类型的日期.任何人都可以为什么会发生这种情况并且可能解决这个问题?

这个代码:

//$decades is a string ex: '1950-1960'

$decade_array=explode('-',$decades);

$date_active=date("M-d-Y", mktime(0, 0, 0, 1,1 , trim($decade_array[0]) ));
$date_inactive=date("M-d-Y", mktime(0, 0, 0, 1, 1, trim($decade_array[1]) ));

echo $date_active.' '.$date_inactive;
Run Code Online (Sandbox Code Playgroud)

php datetime mktime

2
推荐指数
1
解决办法
2246
查看次数

如何在scala中将文件存储为数组?

我正在尝试创建一个代码来读取文件中的行,然后将其作为数组存储在scala中?

以下是我写的代码:

import scala.io.Source
val fname = args(0)
for (line <- Source.fromFile(fname).getLines)
Run Code Online (Sandbox Code Playgroud)

我不知道下一步该做什么?

先感谢您.

scala scala-2.8

2
推荐指数
1
解决办法
887
查看次数

C++ cURL每次都是"来自服务器的空回复"

我正在尝试编写一个C++程序,使用cURL从网站上读取.我已经开始使用cURL示例simple.c中的代码了.如果我完全使用该代码,无论我尝试访问哪个URL,我都会收到错误#52:"来自服务器的空回复".这适用于我尝试的任何网址.如果我从命令行使用cURL,它似乎工作正常.

我的程序的冗长响应是:

*About to connect() to www.google.com port 80 (#0)
* Trying 74.125.91.99...* connected
*connected to www.google.com (74.125.91.99) port 80 (#0)
>GET / HTTP/1.1
Host: www.google.com
Accept: */*

* Empty reply from server
* Connection #0 to host www.google.com left intact
* server returned nothing (no headers, no data)
*Closing connection #0
Run Code Online (Sandbox Code Playgroud)

代码是:

CURL *curl; 
CURLcode res;

curl = curl_easy_init(); 
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com"); 
curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl); 
Run Code Online (Sandbox Code Playgroud)

c++ curl

2
推荐指数
2
解决办法
9466
查看次数

Git 在代码中显示 head,而不是我的更改

我刚刚在 Github 上推送了一些代码,现在我在代码中看到以下内容:

// HelloWorld Layer
@interface GameScene : CCLayer
{

    CCSprite *devil;
    CCParticleFire *fireball; 
    CollisionManager *collisionManager;
    Demon *demon; 
    Spaceship *spaceship;
    Scoreboard *scoreboard;
    Environment *env;
    int lives; 
<<<<<<< HEAD
=======
    CGSize windowSize; 
>>>>>>> 37190b1e49c75517ce26e1040aaaed12bd2a013c
Run Code Online (Sandbox Code Playgroud)

这里发生了什么?

git github

2
推荐指数
1
解决办法
1875
查看次数

试图结合这个unicode字符串列表

试图结合这个unicode字符串列表.我尝试过使用sum和使用join.没运气.

知道我怎么能这样做吗?我只想将所有这些字符串的纯文本输出作为一个大字符串.

[u'\nPanera Bread (NASDAQ: <a class="ticker" href="/stock/pnra#NASDAQ">PNRA</a>) is down 6 percent today over expectations of food inflation of 4.5% in Q3 and 5% for Q4. In addition, Panera Will Raise Menu Prices in Q4.',
 u'\nPNRA recently posted second quarter 2011 earnings of $1.18 per share. Reported earnings also outpaced the prior-year quarter earnings of 85 cents per share. ',
 u"\nBut shares were also lower ahead of the opening bell after the company reported weaker-than-expected same-store sales figures for its …
Run Code Online (Sandbox Code Playgroud)

python string unicode

2
推荐指数
1
解决办法
2986
查看次数

SML - 递归数据类型VS多态数据类型

  1. 有人可以解释它们之间的区别吗?

  2. 此外,在尝试时:

datatype exp = Const of real | Pair of exp * exp;

val my_exp_2 = Pair(Const(1.2),Pair(Const(9.0),Const(2.0)));
Run Code Online (Sandbox Code Playgroud)

口译员给出:

val my_exp_2 = Pair (Const 1.2,Pair (Const #,Const #)) : exp
Run Code Online (Sandbox Code Playgroud)

为什么#符号出现在那里?

谢谢!

sml

2
推荐指数
1
解决办法
1147
查看次数

使用正则表达式查找行号

我试图使用unix sed命令来查找与特定正则表达式匹配的行号.我的文件模式如下

A<20 spaces>
<something>
<something>
..
..
A<20 spaces>
<soemthing>
<something>
Run Code Online (Sandbox Code Playgroud)

我需要所有的行号 A<20 spaces>

我使用sed -n '/A[ ]{20}/'= <file_name>但它不起作用.如果我手动键入二十个空格,它确实有用.

有人可以调整上面的命令使它工作.

sed

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

我的正则表达式验证URL是否正确?

我正在研究在PHP中编写与Perl兼容的正则表达式,以检查给定字符串是否是有效的URL.

现在它按预期工作,但我想知道是否有任何预防措施,我应该用来检查它是否安全的用户输入.该$url变量按原样提交,如纯文本一样.

这是整个功能:

private function real_url($url) {
    return preg_match("/(http|https):\/\/(.*?)\.[a-zA-Z]{2,6}/i",$url);
}
Run Code Online (Sandbox Code Playgroud)

我只想要它来检查httphttps.我并不担心ftp,irc等等.只是网页链接.

它还会检查TLD的持续时间.So "google.asdfasdfasdf"将返回falsegoogle.asdf"将返回true.我该如何解决这个问题?".asdf"显然不是有效的TLD.

我只需要知道两件事:

  • 如何检查给定的URL是否真正合法;
  • 是否对原始用户输入是安全的.

php regex

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

标签 统计

php ×2

android ×1

android-softkeyboard ×1

c++ ×1

curl ×1

datetime ×1

git ×1

github ×1

html ×1

mktime ×1

perl ×1

python ×1

regex ×1

scala ×1

scala-2.8 ×1

sed ×1

sml ×1

string ×1

unicode ×1