Перейти к основному содержанию
Тема: 12345  (Прочитано 25254 раз) предыдущая тема - следующая тема

Re: 12345

Ответ #75
my @lines = <STDIN>;
my %res;
my $fname = '/tmp/uniq.txt';

$res{$_}++ for @lines;
my $content = '';
$content .= $res{$_} . $_ for keys %res;

open my $fh, '>:encoding(UTF-8)' , $fname or die "Can't open $fname: $!";
print $fh $content;
close $fh;

my $size = -s $fname;
print STDOUT $size;

unlink $fname;
Мы, русские, не обманываем друг друга!

Re: 12345

Ответ #76
> <a b c>.elems
3
> <a b c>.head
a
> <a b c>.head(3)
(a b c)
> <a b c>.head(2)
(a b)
> <a b c>.head(.elems - 1)
()
> <a b c>.head(*.elems - 1)
(a b c)

Re: 12345

Ответ #77
Код
say <a b c>.head(.elems - 1)
работает как
say <a b c>.head($_.elems - 1);
что будет результатом зависит от значения переменной $_, поэтому переменная $_ должна иметь нужное значение зараннее


Но как работает вот эта конструкция:
say <a b c>.head(*.elems - 1) # (a b c)
я не могу понять и поэтому не рекомендую её использовать там где нужно передать число.

Re: 12345

Ответ #78
use strict;
use IO::Socket;

my $server = IO::Socket::INET->new(
                LocalPort => 8080,
                Type => SOCK_STREAM,
                ReuseAddr => 1,
                Listen => 10
            ) or die "Can't create server on port 8080 : $@ $/";

while(my $client = $server->accept()){
    $client->autoflush(1);
    my $message = <$client>;
    chomp($message);
    print STDOUT $message;
    close($client);
    last if $message eq 'exit';
}

close($server);
Мы, русские, не обманываем друг друга!

Re: 12345

Ответ #79
use IO::Socket::INET;

# auto-flush on socket
$| = 1;

# create a connecting socket
my $socket = new IO::Socket::INET (
    PeerHost => 'localhost',
    PeerPort => '8080',
    Proto => 'tcp',
);
die "cannot connect to the server $!\n" unless $socket;
print "connected to the server\n";

# data to send to a server
my $req = "hello world";
# my $req = 'exit';
my $size = $socket->send($req);
print "sent data of length $size\n";

# notify server that request has been sent
shutdown($socket, 1);

# receive a response of up to 1024 characters from server
my $response = '';
$socket->recv($response, 1024);
print "received response: $response\n";
 
$socket->close();
Мы, русские, не обманываем друг друга!

Re: 12345

Ответ #80
use strict;
use IO::Socket;

# $| = 1;

my $server = IO::Socket::INET->new(
                LocalPort => 8080,
                Type => SOCK_STREAM,
                ReuseAddr => 1,
                Listen => 10
            ) or die "Can't create server on port 8080 : $@ $/";

while(my $client = $server->accept()){
    $client->autoflush(1);
    my $message = <$client>;
    chomp($message);
    close($client);
    last if $message eq 'exit';
    print STDOUT $message, "\n";
}

close($server);
Мы, русские, не обманываем друг друга!

Re: 12345

Ответ #81
Use kill. If you set a variable in the parent before your fork, you don't need any external options.

my $parent_pid = $$; # Keep a reference to the parent

my $pid = fork();
if ($pid) {
    print "Im going to wait (Im the parent);
    my child is: $pid. The part Im going to use is: $partId \n";
    push(@childs, $pid);
}
elsif ($pid == 0) {
   my $slp = 5 * $_;
   print "$_ : Im going to execute my code (Im a child) and Im going to wait like $slp seconds. The part Im going to use is: $partId\n";
   sleep $slp;
   print "$_ : I finished my sleep\n";

   kill 20, $parent_pid # Send a signal to the parent, 20 is SIGCHLD

   exit($slp);
}

https://stackoverflow.com/a/4035855/1577548
Мы, русские, не обманываем друг друга!

Re: 12345

Ответ #82
 :rage:
Цитата
ERROR 1214 (HY000) at line 2138: The used table type doesn't support FULLTEXT indexes
(нужно обновлять движок базы данных)
нужно ставить операционку посвежее!  :trollface:

Re: 12345

Ответ #83
Viewing the gallery;sa=album;id=20  :bug:


Re: 12345

Ответ #85
1) Высокий блондин в черном ботинке / Follow That Guy with the One Black Shoe / Le grand blond avec une chaussure noire (1972)
http://rutor.is/torrent/366890/vysokij-blondin-v-chernom-botinke_follow-that-guy-with-the-one-black-shoe_le-grand-blond-avec-une-chaussure-noire-1972-bdrip-avc-ot-hqclub

2) Возвращение высокого блондина / The Return of the Tall Blond Man with One Black Shoe / Le retour du grand blond (1974)
http://rutor.is/torrent/366891/vozvrawenie-vysokogo-blondina_the-return-of-the-tall-blond-man-with-one-black-shoe_le-retour-du-grand-blond-1974-bdrip-avc-ot-hqclub


Re: 12345

Ответ #87
Цитата
Извините, раздача недоступна для вашего региона
:angry:
rutracker охуел чтоле?


Re: 12345

Ответ #89
Цитата
Мы не сеем и не пашем, а валяем дурака! С колокольни х... машем, разгоняем облака!(с) (сводный хор госдyмы и совфeда)

 

Быстрый ответ

Обратите внимание: данное сообщение не будет отображаться, пока модератор не одобрит его.