<pre lang="Perl">
#!/usr/bin/env perl
use strict;
print "asd";
</pre>
**bold**
{{irc}}
12:00 <nick> Hello #mojomojo!
{{end}}
`code`
* List item 1
1. Numbered list item
| | Grouping ||
First Header | Second Header | Third Header |
------------ | :-----------: | -----------: |
Content | *Long Cell* ||
Content | **Cell** | Cell |
[Table Title]
`code`
**bold**_italic_
ㅁㄴㅇㅁㄴ엄ㄴ어
머졈ㅇ
머푸커몁
ㅁ어
<pre lang="ABC">
say "Howdy partner.";
</pre>
<pre lang="ASP">
say "Howdy partner.";
</pre>
<pre lang="Perl">
< socket_server.pl >
#!/usr/bin/env perl
use strict;
use warnings;
use Socket;
use Carp;
my $EOL = "\015\012"; # \n 과 같음 End Of Line의 약자
sub logmsg { print "$0 $$: @_ at ",scalar localtime(), "\n" } # 시스템콘솔에 로그를 출력하기위한 함수
my $port = shift || 2000; # 인자로 받은 배열에서 첫번째 원소를 꺼내 입력 하거나 기본값 입력
die "invalid port" unless $port =~ /^ \d+ $/x; # //x modifier는 정규식 확장으로 공백이나 줄바꿈을 무시한다.
my $proto = getprotobyname("tcp"); # tcp protocol 얻음
socket ( my $server, PF_INET, SOCK_STREAM, $proto ) || die "socket: $!";
setsockopt ( $server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1))
|| die "setsockopt : $!";
bind( $server, sockaddr_in($port, INADDR_ANY)) || die "bind : $!";
listen($server, SOMAXCONN) || die "listen: $!";
logmsg "server started on port $port";
my $paddr;
$SIG{CHLD} = \&REAPER;
for ( ; $paddr = accept(Client, $server); close Client) {
my ( $port, $iaddr) = sockaddr_in($paddr);
my $name = gethostbyaddr( $iaddr, AF_INET);
logmsg "connection from $name [",
inet_ntoa( $iaddr ), "] at port $port";
print Client "hello there, $name, it's now ",
scalar localtime(), $EOL;
}
</pre>