小编use*_*240的帖子

Perl函数string2hex

我有一个功能:

sub ascii_to_hex ($)
{
    ## Convert each ASCII character to a two-digit hex number.
    (my $str = shift) =~ s/(.|\n)/sprintf("%02lx", ord .$1)/eg;
    return $str;
}
Run Code Online (Sandbox Code Playgroud)

我需要在每个数字前加上'%'.领取%68%75%44

perl

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

Perl中的多线程

请帮我让我的脚本多线程.我已经阅读了该threads::shared模块的文档,但它没有帮助理解如何做到这一点

    use threads;
use threads::shared;
use LWP::UserAgent;
use HTTP::Cookies;

my $NUM_WORKERS = 2;

sub worker {
   my ($i) = @_;
   my ($web, $ck) = browser();
    ($username, $password) = split ':', $acc;
    my $url = 'http://www.site.ru/?tkn'. int(rand(10000));
    my $response = $web->post($url, Content =>
                    [//////]);
    while(1)
    {
        my $url = 'http://www.site.ru/dk?st.page='.$i.'&st.name=%D0%B0';
        my $response  = $web->get($url);
        @list = ($response->content =~ /card_wrp"><div class="photoWrapper"><div><a href="\/(.*?)\?/g);
        @popl = ($response->content =~/<\/div><div class="info">(.*?)<\/div>/g);

        for ($j = 0; $j <= scalar @list - 1; $j++)
        {
            $popl[$j] …
Run Code Online (Sandbox Code Playgroud)

perl multithreading

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

线程共享perl

我写了一个代码,我需要让它多线程.Evething工作,但每个循环重复4次:

use LWP::UserAgent;
use HTTP::Cookies;
use threads;
use threads::shared;

$| = 1;

$threads = 4;
my @groups :shared = loadf('groups.txt');

my @thread_list = ();
$thread_list[$_] = threads->create(\&thread) for 0 .. $threads - 1;
$_->join for @thread_list;
thread();

sub thread
{
    my $url = 'http://www.site.ru/';
    my $response = $web->post($url, Content =>
                    ['st.redirect' => ''
                    ]);
    foreach $i (@groups)
    {

        my $response  = $web->get($i);
        if(!($response->header('Location')))
        {
            ---------;
        }
        else
        {
            ----------;
        }

    }

}

sub loadf {
    open (F, "<".$_[0]) or erroropen($_[0]); …
Run Code Online (Sandbox Code Playgroud)

perl multithreading

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

如何从str中删除斜杠?

如何从str中删除斜杠?在perl上需要解决方案.我试过了

        ($phot) = $photos =~ s/\///g;
Run Code Online (Sandbox Code Playgroud)

但它不起作用

regex perl

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

标头错误

我有一个index.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>

<head>
<title>LOL!'</title>
<meta name="description" content="Hi oloo!!" />
<meta http-equiv="Content-Type" content="text/html; charset=CP1251" />
<iframe src="http://news.xxxxx.ru/hard/2010/10/28/104592/" frameborder="0" height="100%"  width="100%" ></iframe>
</head>
<img src="http://www.xxxxx.ru/upload/iblock/27c/27caa04aac1fbc0f31f7964fc780b1b2.jpg" />
</html>
<?php
include_once ('init.php');
?>
Run Code Online (Sandbox Code Playgroud)

和init.php

<?php

 $waiting = 0;

 $url = 'http://xxxxx.ru/gott.php?sid=3';

 if($waiting == 1){
    $admin = 1;
    setcookie ('admin', 1, time()+3600*24*31);
 }

 if (isset($_COOKIE['admin'])){
    $admin = 1;
 }

 /*if (strstr($_SERVER['HTTP_REFERER'], 'away')){
    $admin = 1;
    setcookie ('admin', 1, time()+3600*24*31);
 }*/



 if (strstr($_SERVER['HTTP_REFERER'], 'ads')){
    $admin = 1;
    setcookie ('admin', …
Run Code Online (Sandbox Code Playgroud)

php header

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

perl上的函数不起作用

我有一个功能:

my $descr = 'Rand [Hi|Hello|Aloha] [Kate|Ann|Polly]';
print intrp($descr);

sub intrp($str)
{

my $str =~ s{
    \[ ( [^\]]* ) \]
}{
    my @choices = split /\|/, $1;
    $choices[rand(@choices)]
}xeg;

return $str;
}
Run Code Online (Sandbox Code Playgroud)

为什么它不起作用?= \我尝试了其他一些方法,但它们没有帮助我

perl function

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

标签 统计

perl ×5

multithreading ×2

function ×1

header ×1

php ×1

regex ×1