小编Bnj*_*jmn的帖子

如何使用你编写的perl模块?

我刚刚编写了我的第一个Perl模块,并且无法使用我生成的脚本.以下是我尝试运行使用新创建的模块的脚本时Perl解释器显示的错误.

错误信息:

scraper_tools_v1.pm did not return a true value at getYid.pl line 5.
BEGIN failed--compilation aborted at getYid.pl line 5.
Run Code Online (Sandbox Code Playgroud)

scraper_tools_v1.pm是我编写的Perl模块,getYid.pl是试图利用scraper_tools_v1.pm模块的Perl脚本.

以下是scraper_tools_v1.pm文件的代码:

#!/usr/bin/perl

package scraper_tools_v1;

use strict;
use warnings;
use WWW::Curl::Easy;

# Note this function expects a single parameter which should be in the form of a URL

  sub getWebPage($)
  {
    # Setting up the Curl parameters
    my $curl = WWW::Curl::Easy->new; # create a variable to store the curl object

    # A parameter set to 1 tells the library to …
Run Code Online (Sandbox Code Playgroud)

perl perl-module

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

SQLException:没有这样的表

现在我在连接数据库时遇到了一些麻烦.我知道我正在寻找的表存在,因为当我使用命令行访问它们时,可以查询它们.

可能是一些轻微的疏忽,但我会喜欢一些帮助.

这是我连接到数据库包持久性的地方;

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;


public class DBRegistry {

    private static DBRegistry db = null;
    private static Connection connection = null;

    private DBRegistry() {};

    public static synchronized DBRegistry getUniqueInstance() {
        if (db == null) {
                db = new DBRegistry();
                return db;
        }
        else return db;
    }

    public synchronized Connection getDBConnection() {
            try {
                Class.forName("org.sqlite.JDBC");
                connection = DriverManager.getConnection("jdbc:sqlite:src/database/taskMan.db");
                return connection;
            } 
            catch (SQLException e) {e.printStackTrace();} 
            catch (ClassNotFoundException e) {e.printStackTrace();}
            return null;
    }

    public synchronized void closeConnection() { …
Run Code Online (Sandbox Code Playgroud)

java sqlite jdbc

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

不能将未定义的值用作文件句柄引用

首先,我搜索了论坛,但没有找到我的问题.我正在运行安装了perl 5.10的Ubuntu.

我在执行脚本后收到以下错误:

 "Can't use an undefined value as filehandle reference at scraper.pl line 17"
Run Code Online (Sandbox Code Playgroud)

这是我的剧本....

#!/usr/bin/perl -W
use strict;
use warnings;

use WWW::Curl::Easy;


my $curl = WWW::Curl::Easy->new;

$curl->setopt(CURLOPT_HEADER, 1);
$curl->setopt(CURLOPT_URL, 'http://something.com');


my $response_body;
$curl->setopt(CURLOPT_WRITEDATA,\$response_body);

my $return_code = $curl->perform;

if ($return_code == 0)
{
  my $response_code = $curl->getinfo(CURLINFO_HTTP_CODE);
  print ("Success ".$response_code);
}
else
{
  # Error Code
  print ("An error occured: ".$return_code." ".$curl->strerror($return_code)." ".$curl->errbuf."\n");
}

# EOF
Run Code Online (Sandbox Code Playgroud)

这里的任何帮助将不胜感激.

谢谢,

perl libcurl

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

使用Visual Studio 2010学习使用C#编写的新库的最佳方法是什么?

我最近发现需要学习一个没有大量文档来进行更改的新库.代码是用C#编写的,我使用Visual Studio 2010作为编辑器.我正在尝试学习的库确实附带了一个示例驱动程序,但它也相当庞大且复杂.我想知道VS中是否有任何设施允许我在执行时观察代码,以便我在运行时学习.

是否有人知道我应该在VS中查看的任何工具,另外,通常可以指定我可能用于快速学习如何使用新库的任何其他方法.

谢谢

c# visual-studio-2010

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

标签 统计

perl ×2

c# ×1

java ×1

jdbc ×1

libcurl ×1

perl-module ×1

sqlite ×1

visual-studio-2010 ×1