PerlでHello World

 

 


(20)
https://qz.tsugumi.org/Perl_IO_Socket_INET.html
https://www.geekpage.jp/programming/perl-network/simple-http-serv.php


perl -v

vim hello.pl
#! /usr/bin/perl
print "Hello World!\n"

perl hello.pl


--
vim web.pl

#!/usr/bin/perl

use IO::Socket;

my $s = IO::Socket::INET->new(
LocalAddr => "ubu20",
LocalPort => 8080,
Proto => "tcp",
Listen => 10,
ReuseAddr => 1
) or die $!;

$s->listen or die $!;

while(my $c = $s->accept){
my $q = $c->getline;
print $q;
$c->print("HTTP/1.0 200 OK\r\n");
$c->print("Content-Type: text/html\r\n");
$c->print("\r\n");
$c->print("Hello World!\n");
$c->close;
}

$s->close;

perl web.pl

(10)

perl -v

vim hello.pl
#! /usr/bin/perl
print "Hello World!\n"

perl hello.pl


--
vim web.pl

#!/usr/bin/perl

use IO::Socket;

my $s = IO::Socket::INET->new(
LocalAddr => "deb10",
LocalPort => 8080,
Proto => "tcp",
Listen => 10,
ReuseAddr => 1
) or die $!;

$s->listen or die $!;

while(my $c = $s->accept){
my $q = $c->getline;
print $q;
$c->print("HTTP/1.0 200 OK\r\n");
$c->print("Content-Type: text/html\r\n");
$c->print("\r\n");
$c->print("Hello World!\n");
$c->close;
}

$s->close;

perl web.pl

 

(8)
perl -v

vim hello.pl
#! /usr/bin/perl
print "Hello World!\n"

perl hello.pl


--
vim web.pl

#!/usr/bin/perl

use IO::Socket;

my $s = IO::Socket::INET->new(
LocalAddr => "mmm165",
LocalPort => 8080,
Proto => "tcp",
Listen => 10,
ReuseAddr => 1
) or die $!;

$s->listen or die $!;

while(my $c = $s->accept){
my $q = $c->getline;
print $q;
$c->print("HTTP/1.0 200 OK\r\n");
$c->print("Content-Type: text/html\r\n");
$c->print("\r\n");
$c->print("Hello World!\n");
$c->close;
}

$s->close;

perl web.pl

(2019)

http://strawberryperl.com/


perl -v

notepad hello.pl
#! /usr/bin/perl
print "Hello World!\n"

perl hello.pl


--
notepad web.pl

#!/usr/bin/perl

use IO::Socket;

my $s = IO::Socket::INET->new(
LocalAddr => "mmm160",
LocalPort => 8080,
Proto => "tcp",
Listen => 10,
ReuseAddr => 1
) or die $!;

$s->listen or die $!;

while(my $c = $s->accept){
my $q = $c->getline;
print $q;
$c->print("HTTP/1.0 200 OK\r\n");
$c->print("Content-Type: text/html\r\n");
$c->print("\r\n");
$c->print("Hello World!\r\n");
$c->close;
}

$s->close;

perl web.pl