Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CGIプログラムを書いてみた
Search
uutan1108
August 25, 2024
Programming
390
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CGIプログラムを書いてみた
ゆるWeb勉強会@札幌 #27 / フロントエンドカンファレンス北海道2024 お疲れ様会
https://mild-web-sap.connpass.com/event/327040/
uutan1108
August 25, 2024
More Decks by uutan1108
See All by uutan1108
四畳半神話大系から学ぶ判断における経験の必要性
ohmori_yusuke
1
43
エンジニアとQAエンジニアを繋いでくれた振る舞い駆動開発(Behaviour-Driven Development)
ohmori_yusuke
0
280
Designing a Cross-Disciplinary Engineering Community Through Anime
ohmori_yusuke
3
120
コミュニティ・勉強会を作るのは目的じゃない
ohmori_yusuke
1
410
映画のエンドロール風の動画を自動生成するツールを作った
ohmori_yusuke
2
110
アウトプットは“成果物”じゃなく“副産物”だった話
ohmori_yusuke
1
160
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
930
仕様がそのままテストになる!Javaで始める振る舞い駆動開発
ohmori_yusuke
8
6.2k
勉強会から始まった僕のDevRel~新卒エンジニアがつないだ2年間の軌跡~
ohmori_yusuke
2
540
Other Decks in Programming
See All in Programming
Apple Intelligence を用いた個人情報誤送信防止、及びユーザーリクエスト体験の改善について
yukiny
0
350
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
210
すこし踏み込む CancellationToken
htkym
2
1.7k
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
sbt 2.0: takeoff
eed3si9n
0
160
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
Event is what happens
moro
2
770
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
golang-bob.pdf
iwatsukayura
0
130
Next.js: The final boss of Web Performance
guaca
0
250
Featured
See All Featured
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
890
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.2k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
360
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Navigating Weather and Climate Data
rabernat
0
560
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.4k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
エンジニアに許された特別な時間の終わり
watany
109
250k
Side Projects
sachag
456
43k
First, design no harm
axbom
PRO
2
1.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Transcript
PerlでCGIスクリプトを書いてみた ゆるWeb勉強会@札幌 #27 / フロントエンドカンファレンス北海道2024 お疲れ様会 うーたん
自己紹介
自己紹介 • うーたん ◦ X:@uutan1108 • 株式会社ゆめみ ◦ 新卒2年目 ◦
サーバーサイドエンジニア • 趣味 ◦ アニメを観ること
私とゆるWeb勉強会@札幌
初めてのLT発表|うーたん https://note.com/uutan1108/n/nffce0e70facd
オンラインの時のゆるWebだったけど楽しかった • ワイワイする時間がいい • ハッシュタグでリアクションしてくださる方が多くて いい • 当時大学生の私でも発表しやすくてよかった • 司会、運営のtacckさんから感想がもらえるのがいい
以上、私とゆるWeb勉強会@札幌でした
本題 「PerlでCGIスクリプトを書いてみた」
CGIとは
CGIとは? CGI とは Common Gateway Interface の略です。通常の ページでは、あらかじめ用意された HTML ページを表示す
るだけですが、CGI を用いることにより、例えば、以下の ようなページを作成することができるようになります。 - カウンター - チャット - 掲示板 - アンケートフォーム CGIの概要 - とほほのWWW入門 https://www.tohoho-web.com/wwwcgi1.htm
CGIスクリプトとは 「CGIプログラム」のうち、Perl、awk、sh などコンパイ ル作業が不要なスクリプト言語で記述されたものを「CGI スクリプト」と呼びます。CGI プログラムは Perl で記述 されたものが多いですが、環境変数と標準入力を参照でき て、結果を標準出力に書き出せるものであれば、C言語、
C++言語、VisualBasic でも何でも構いません。 CGIの概要 - とほほのWWW入門 https://www.tohoho-web.com/wwwcgi1.htm
CGIスクリプトとは 「CGIプログラム」のうち、Perl、awk、sh などコンパイ ル作業が不要なスクリプト言語で記述されたものを「CGI スクリプト」と呼びます。CGI プログラムは Perl で記述さ れたものが多いですが、環境変数と標準入力を参照でき て、結果を標準出力に書き出せるものであれば、C言語、
C++言語、VisualBasic でも何でも構いません。 CGIの概要 - とほほのWWW入門 https://www.tohoho-web.com/wwwcgi1.htm
まずはPerlでCGIを書いてみる
アイドルマスター(765プロ、346プロ) のアイドル 検索アプリ
None
None
機能 - キャラクターの情報で検索 - クエリパラメータで検索機能 - キャラクターの名前漢字または名前カナで検索機能
構成図
Perl(CGIスクリプト) +Apache+MySQL
None
Perlを書いた感想
書いてみてへぇと思ったところを紹介
サブルーチン🤔
ユーザーが定義する関数 Perl では様々な組み込み関数が用意されていますが、自分 で関数を定義することも可能です。 ユーザーが定義する関数をサブルーチンと呼びます。 Perl | サブルーチン https://www.javadrive.jp/perl/sub/
もう少し詳しく
サブルーチンとは🤔 #!/usr/bin/perl sub hello { my ($world) = @_; return
"Hello " . $world; } my $result = hello("World"); print $result;
サブルーチンとは🤔 #!/usr/bin/perl sub hello { my ($world) = @_; return
"Hello " . $world; } my $result = hello("World"); print $result; サブルーチンを呼び出す
サブルーチンとは🤔 #!/usr/bin/perl sub hello { my ($world) = @_; return
"Hello " . $world; } my $result = hello("World"); print $result; @_ に引数”World”
サブルーチンとは🤔 #!/usr/bin/perl sub hello { my ($world) = @_; return
"Hello " . $world; } my $result = hello("World"); print $result; . で“Hello”と”World”を連結
サブルーチンとは🤔 #!/usr/bin/perl sub hello { my ($world) = @_; return
"Hello " . $world; } my $result = hello("World"); print $result; 文字列の Hello World が出力
へぇ 💡
$ と @ の違い🤔
$と@の違いは、データの種類 $: スカラ変数を表し、単一の値(例えば、数字や文字列) を保持する 例: $scalar = 10; → 1つの値を保持する
@: 配列を表し、複数の値を保持する 例: @array = (1, 2, 3); → 複数の値を保持する
$: スカラ変数 #!/usr/bin/perl my $message = "Hello"; print $message; 文字列の
Hello が出力
@: 配列 #!/usr/bin/perl my @nums = (1, 2, 3); print
@nums; 配列の 123 が出力
もう少し詳しく
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data;
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data; 配列のリファレンス
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; 配列のリファレンス
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; print $array_ref > ARRAY(0x560c6a730788) リファレンスが得られる
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data; デリファレンス
$ と @ の違いは🤔 #!/usr/bin/perl my @array = @$array_ref; デリファレンス
$ と @ の違いは🤔 #!/usr/bin/perl my @array = @$array_ref; print
$array_ref > ARRAY(0x560c6a730788) print @$array_ref; > 123 リファレンス先の値を参照して出力する
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data; 配列の (1, 2, 3) を出力
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data; 配列の先頭の要素を $data に代入
$ と @ の違いは🤔 #!/usr/bin/perl my $array_ref = [1, 2,
3]; my @array = @$array_ref; print @array; my ($data) = @array; print $data; $data の 1 を出力
へぇ 💡
最後に
アイドル図鑑のコード
None
タグの閉じ忘れでスタイル崩れてしんどかった
宣伝
PHPカンファレンス沖縄2024前夜祭 で登壇します PHPカンファレンス沖縄2024前夜祭 - connpass https://phpcon-okinawa.connpass.com/event/324902/
Scrum Fest Mikawa 2024 で登壇します Scrum Fest Mikawa 2024 -
新卒エンジニアが組織に馴染むために勉強会を主催して職能間の境界を越える | ConfEngine - Conference Platform https://confengine.com/conferences/scrum-fest-mikawa-2024/proposal/20268
アイドル名簿(今回作ったアプリのコード) OHMORIYUSUKE/perl-mysql-apache-on-docker https://github.com/OHMORIYUSUKE/perl-mysql-apach e-on-docker
お わ り