七行プログラミング (452レス)
上下前次1-新
384(1): nobodyさん [sage] 2006/01/25(水) 22:06:31 ID:??? AAS
 初回起動時からの累計と過去1週間の日別カウンタ。 
 設定を変えれば一日の時間別みたいな使い方もできる。 
  
 ($f,$l,$z)=qw{./counter.dat 7 5};use CGI':all';sub d{sprintf 
 '%d年%02d月%02d日(%s)',1900+$_[5],1+$_[4],$_[3],(qw/日 月 火 水 木 金 土/)[$_[6 
 ]]}sub n{sprintf"%0${z}d回",shift}$n=time;$d=24*60*60;$p=$n-$n%$d;if(open F, 
 "+<$f"){eval{flock F,2};($s,@d)=map[split/\s+/],<F>;$s->[0]||=$n;$s->[1]++;$p== 
 $d[0][0]?$d[0][1]++:unshift@d,[$p,1];$n-=$d*$l;seek F,0,0;printf F"%d\t%010d\n" 
 ,@$_ for@d=($s,grep$n<$_->[0],splice@d,0,$l);truncate F,tell F;close F}charset 
 '';print header,ul map{li b(n$_->[1]),d localtime$_->[0]}@d 
385: nobodyさん [sage] 2006/01/25(水) 22:08:08 ID:??? AAS
 7CMS 
 このスレで作った >>365365(5): nobodyさん [sage] 2006/01/21(土) 13:50:12 ID:??? AAS
 #!/usr/bin/perl 
 my@d=([qw/? ? ? ? ? ? ? ? ? ? ? ? ? ?/],[qw/☆ △ ■/]); 
 my$c='Shift_JIS';my$l='ja';use CGI':standard';my@r=(0)x@d; 
 print header(-charset=>$c),start_html(-encoding=>$c,-lang=>$l),start_form, 
 (map{my$i=$_;ul li[(map{$r[$i]+=param($_);$_.textfield -name=>$_}@{$d[$i]}), 
 "計 $r[$i]"]}0..$#d),ul(li"$r[1]÷$r[0]=".eval{$r[1]/$r[0]}),submit,end_form, 
 end_html;  
 >>378378(3): 376 [sage] 2006/01/23(月) 21:15:02 ID:??? AAS
 ($f,$s,$r,@p)=qw/file 8 1 _ ● 〇/;use Storable;use CGI':all';sub f{$u=1;my($y 
 ,$x,$c)=@_;if(0>($t=$r*$m[$y][$x])){$m[$y][$x]*=f($y+$p,$x+$n,1)}elsif($c&$t){ 
 $u=-1;$z++}$u}$$_=param($_)%($s+1)for qw/x y/;@m=map[(0)x($s+1)],0..$s+1;map$m[ 
 $s/2+$_/2][$s/2+$_%2]=$_%3?1:-1,0..3;($r,@m)=@{retrieve$f}if-s$f;$o=\$m[$y][$x] 
 ;if($y&&$x&&!$$o){for(0..7){($p,$n)=map sprintf('%.f',$_),sin($i=$_*0.78),cos$i 
 ;f$y+$p,$x+$n}$$o=$r,$r*=-1 if$z}store[$r,@m],$f;charset '';print header,$p[$r] 
 ,table Tr[map{$i=$_;td[map a({href,"?y=$i&x=$_"},$p[$m[$i][$_]]),1..$s]}1..$s] 
  
 括弧はずしすぎでバグっていたので修正 
 ファイル名省略すると Lynx じゃ動かないね。  
 >>381381(1): nobodyさん [sage] 2006/01/24(火) 00:41:03 ID:??? AAS
 @x='A'..'G';@y=1..10;@s=qw/合計 平均/;use CGI':all';charset '';print header, 
 style({type,'text/css'},'table{border-collapse:collapse}td,input{text-align: 
 right;width:70px}td,th{border:1px solid gray}'),start_form,table(Tr[th(['',@x, 
 @s]),(map{$i=$_;$s=0;$n=0;td[$_,(map{$p=param"$x[$_]$i";($t=$s)==($s+=$p)||$n++ 
 ;($t=$r[$_])==($r[$_]+=$p)||$v[$_]++;textfield"$x[$_]$i"}0..$#x),($r[@x]+=$s,$s 
 ,eval{$s/$n})[1,2]]}@y),td([$s[0],@r,'']),td[$s[1],map($v[$_]?sprintf('%.3f',( 
 $c++,($t=$r[$_]/$v[$_]),$v+=$t)[1]):'',0..@x),eval{$v/$c}]]),submit,end_form; 
  
 >>368 がいまいち糞コードになりきれていなかったので平均の計算も追加。おやすみ〜 ノシ  
 >>384 をモジュール化して一元管理する。 
 サードパーティー製品でもCGI.pmを使ったものなら大丈夫かも。 
 >>137 >>274 は一応動いた。 
 使い方は全部同じディレクトリに入れればいいだけだから。 
  
 use CGI':all';$d=param '*';@r=[$0=~/([^\\\/]+)$/,'START'];$p=$`;for$n(<*>){if($r 
 [0][0]ne$n&&$n=~/\.cgi$/){$r='';chdir$p;open F,$n;read F,$c,-s F;tie*G=*STDOUT, 
 'main';eval"package C$`;$c";untie*G;$r=~s/^.+?(\r?\n){2}//s;$r=~s/(<a\s.*?\?)(. 
 *?>)/$1*=$d&$2/gisx;$r=~s!(?=</for)!hidden -name,'*',-value,$d!egi;push@r,[ 
 $n,$r.$@]}}AUTOLOAD{ref(shift)?($r.=join'',@_):bless[]}charset '';put header, 
 table Tr td{style=>'vertical-align:top;text-align:left;border:1px solid gray'}, 
 [ul(li[map a({href,"?*=$_"},$d==$_?b($r[$_][0]):$r[$_][0]),0..$#r]),$r[$d][1]] 
386: nobodyさん [age] 2006/01/26(木) 18:42:38 ID:??? AAS
 hage 
387: nobodyさん [sage] 2006/01/26(木) 21:31:03 ID:??? AAS
 7メル 
  
 ($p,$t,$s)=('/usr/sbin/sendmail','mail@example.com','メールフォームから');use 
 CGI':all';$$_=param $_ for qw/f m/;($f)=$f=~/^([\w.-]{1,64}\@[\w.-]{1,128})$/i; 
 ($m=substr$m,0,2**16)=~tr/\0/ /;$m=~s/\r\n?/\n/g;$m=~s/^\.$/../gm;charset '';put 
 header,startform,'あなたのメールアドレス',textfield(-name,'f'),br,'メッセージ', 
 br,textarea(-name,'m',-rows,10,-cols,60),br,submit,endform;if($f&&$m&&open M, 
 "| $p -t"){print(M join"\n",'Content-Transfer-Encoding: 8bit',"Reply-To: <$f>", 
 "To: <$t>","Subject: $s",'',$m,'')&&put '管理者へ送信しました。';close M} 
388: nobodyさん [sage] 2006/01/26(木) 21:31:54 ID:??? AAS
 7カレ 
  
 @c=([('silver')x 7],[('red',('black')x 5,'blue')],'lavender');use CGI':all';$s= 
 24*60*60;@t=localtime($t=time);@r=td{align=>'right',bgcolor=>$c[2]},font{color 
 =>$c[1][$t[6]]},b $t[3];@t1=localtime($i=$t-$s);while($t[4]==$t1[4]||$t1[6]<6){ 
 unshift@r,td{align=>'right'},font{color=>$c[$t[4]==$t1[4]][$t1[6]]},$t1[3];@t1= 
 localtime($i-=$s)}@t2=localtime($i=$t+$s);while($t[4]==$t2[4]||0<$t2[6]){push@r 
 ,td{align=>'right'},font{color=>$c[$t[4]==$t2[4]][$t2[6]]},$t2[3];@t2=localtime 
 ($i+=$s)}charset '';put header,table Tr[map join('',@r[7*$_..7*($_+1)-1]),0..$#r] 
389: nobodyさん [age] 2006/01/26(木) 21:32:37 ID:??? AAS
 何でもいいからボケッと見てないでおまいらも参加しる! 
390(1): nobodyさん [] 2006/01/27(金) 16:58:32 ID:KYetQvuJ(1) AAS
 require "cgi-lib.pl"; 
 &ReadParse;if($ENV{'REQUEST_METHOD'} eq 'POST'){if ($in{'imagefile'}) 
 {open(WRITEFILE,'>', "datafile");binmode(WRITEFILE);print WRITEFILE $in{'imagefile'};close(WRITEFILE);}} 
  
 7うp掲示板 
 これ以上はムリポ
391: nobodyさん [sage] 2006/01/27(金) 22:17:22 ID:??? AAS
 >>390 
 安全を保ちつつ複数ファイルに対応しる! 
392: nobodyさん [sage] 2006/01/27(金) 22:18:05 ID:??? AAS
 7ナビ 
 同一階層以下のHTMLにリンクを貼る。携帯用サイトマップみたいなもん。 
  
 $d='./';$e='s?html?';$n=10;@l=(['prev',-1],['next',1]);use CGI':all';sub r{my( 
 $d,$e)=@_;map{if(-d){r($_,$e)}elsif(/\.$e$/&&$p<=$c++&&$c<=$p+$n&&open F,$_){-B 
 ||read F,$h,2**16;close F;$h=~/>\s*([^<>]*?)\s*<\/ti/is;[$_,$1||$_]}else{()}} 
 <$d/*>}$p+=param 'p';($d)=$d=~/(.+?)[\\\/]*$/;@r=r$d,$e;if($p<0){$p=$c-$c%$n;$c 
 =0;@r=r$d,$e}elsif(!@r){$p=0;$c=0;@r=r$d,$e}charset '';put header,dl dt(map a({ 
 href=>"?p=".($p+$n*$_->[1])},$_->[0]),@l),dd{style=>'margin:0px'},join"\n",ol({ 
 start=>1+$p},li[map a({href=>$_->[0]},$_->[1]),@r]),p"$c files" 
393: nobodyさん [sage] 2006/01/27(金) 22:19:01 ID:??? AAS
 7 httpd 
 これはCGIじゃないよ。 
 起動でlistenと外部リンク[html]:127.0.0.1で表示。 
 Options Indexes があるはずも無いのでファイル名まで指定。 
  
 if(!grep(/^SERVER/i,keys%ENV)&&socket(S,2,1,0)&&setsockopt(S,65535,4,pack'l',1) 
 &&bind(S,pack'S n a4 x8',2,80)&&listen S,1){select+(select(S),$|=1)[0];while( 
 accept C,S){select+(select(C),$|=1)[0];@r=unpack"C*",getpeername C;if(recv(C,$d 
 ,8192,0)&&$d=~/^GET ([\x21-\x7e]{1,256}) H/ and$p=join'/',map{s/\.+/./g;$_}grep 
 length,split/[\\\/]+/,$1){print C 'HTTP/1.0 ',do{$n="\r\n\r\n";if(open F,"./$p" 
 ){binmode F;read F,$b,-s F;close F;"200$n$b"}else{"404${n}Not Found\n"}};undef 
 $b}close C;printf"$d%d.%d.%d.%d:%d\n%s\n",@r[4..7],256*$r[2]+$r[3],'-'x 64}} 
394: nobodyさん [age] 2006/01/30(月) 04:20:47 ID:??? AAS
 みんながんがれ!! 
395: nobodyさん [sage] 2006/02/10(金) 18:36:50 ID:??? AAS
 うぅ、ここPerl限定なのか… 
 PHPスレ欲しいな。 
396: nobodyさん [sage] 2006/02/10(金) 18:41:19 ID:??? AAS
 phpもOKみたいだぞ。 
397: クロエ [] 2006/02/12(日) 00:31:01 ID:VpXKciXc(1) AAS
 >>368368(2): 365 [sage] 2006/01/22(日) 10:02:46 ID:??? AAS
 >>367 
 仕様変更は34,000円からになっておりますw 
 話の流れがわからない人は2chスレ:tech 
  
 >>365はかなりゆとりがあったので7Excelにしてみた。 
 スタイルシートを別ファイルにしてもいいならまだまだいけそうだ。 
 #!/usr/bin/perl 
 @x='A'..'G';@y=1..10;$c='Shift_JIS';use CGI':all';@r=(0)x(@x+1);print header( 
 -charset=>$c),start_html(-encoding=>$c,-lang=>'ja',-head=>style({-type=> 
 'text/css'},'table{border-collapse:collapse}input,th{width:50px}td{text-align: 
 right}td,th{border:1px solid gray}')),start_form,table(Tr(map th($_),'',@x,''), 
 (map{$i=$_;$s=0;Tr td[$_,(map{$p=param"$i$x[$_]";$s+=$p;$r[$_]+=$p;textfield 
 "$i$x[$_]"}0..$#x),($r[-1]+=$s,$s)[1]]}@y),Tr td['',@r]),submit,end_form,end_html  
365だと367の最後の×100が反映されないんですが…。せんせぇ、お願いします。 
398: nobodyさん [] 2006/02/15(水) 07:50:04 ID:Q8DDLS00(1) AAS
 てめえらどうした!? 
 探求心はつきたか? 
399: nobodyさん [] 2006/02/19(日) 19:16:08 ID:YpSh6qb6(1) AAS
 昔作った今月のカレンダー表示スクリプト。 
  
 ($$,$:,$;,$=)=(localtime)[3..6];printf"%2d%s",$_,++$=%7?$":$/for(print($;+ 
 1900,'/',$:+1,"/$$\n",$"x(($=-=$$-1)%7*3))..28+($:-1?3-$:%7%2:!($;%4))) 
400(2): nobodyさん [] 2006/02/28(火) 10:19:55 ID:5vE9CKm+(1) AAS
 #!/usr/bin/perl  
 if($ENV{'REQUEST_METHOD'}eq'POST'){read(STDIN,$b,$ENV{'CONTENT_LENGTH'});  
 foreach(split(/&/,$b)){($c,$d)=split(/=/,$_);$d=~tr/+/ /;  
 $d=~s/%([a-f\d]{2})/pack('H2',$1)/egi;$form{$c}=$d}open(F,'>>z.txt');  
 print F "$form{y}\n";close F}print"Content-type:text/html\n\n<html>  
 <form action=x.cgi method=post><input type=text name=y><input type=submit>  
 </form><br><br>";open(F,'z.txt');while(<F>){print "$_<br>\n"}print'</html>';  
401: nobodyさん [] 2006/03/10(金) 16:20:32 ID:OL3a1OF8(1) AAS
 在庫から 7wikimini ドゾ。 
 YukiWikiMini の7行版みたいな感じです。 
 実行するにはWという名前のフォルダが必要です。 
  
 use CGI":all";charset$c=Shift_JIS;*i=*param;$f=FrontPage;$i=Index;$u=Update;$F= 
 i(P)||$f;sub e{a{href,"?E=1&P=".pop},@_}sub l($){a{href,"?P=@_"},@_}chdir W;$E= 
 i E;$U=$F eq$u;$I=$F eq$i;$,=$/;if($_=i T){open F,">$F";print F$_}$H=$I+$U;$t=$ 
 H?join$/,map{localtime((stat)[9]).$_}sort{$U&&-M$a<=>-M$b}<*>:($/=!open F)||$E? 
 <F>:escapeHTML<F>;$E||$t=~s/([A-Z][a-z]+){2,}/-f$&?l$&:$&.e"?",$&/eg;put header 
 ,start_html(-title=>$F,lang,ja,encoding,$c),l$f,$H?():e(Edit,$F),l$i,l$u,h1($F) 
 ,$E?startform.hidden(P).textarea(T,$t,20,80).submit.endform:pre($t),$P,end_html 
  
 ページ削除機能が実装されてないので、もうちょっと改良が必要っす。 
402(2): nobodyさん [sage] 2006/03/10(金) 18:39:49 ID:??? AAS
 おまいら、このスレ出ている7行プログラムを、 
 インデント付けて整形するプログラムをどうか7行以内で書いてもらえませんか。 
403: nobodyさん [sage] 2006/03/10(金) 20:42:29 ID:??? AAS
 >>402 
 モジュールの力を借りずに Perl の構文解析器を七行で書くのは 
 絶望的だし、この手のコードは多分に恣意的なインデントや桁揃え 
 をしないと読み易くもならない。 
  
 ので、手っ取り早く「バラし」て流れを読みたいのなら、これで充分。 
 perl -MO=Deparse script.in > script.out 
  
 もちろんチャレンジ精神を否定しているのではないよ。:o) 
404(1): nobodyさん [sage] 2006/03/11(土) 14:32:34 ID:??? AAS
 >>402 
 ム板の7行スレの方であったかもしれぬ。なかったかもしれぬ。 
405: nobodyさん [sage] 2006/03/11(土) 17:24:08 ID:??? AAS
 >>404 
 あったよ。Part 2 の 105,129,135,162,163,169,170 辺り。 
  
 …まぁ、通ってきた道なわけですよ。 
406: nobodyさん [sage] 2006/03/12(日) 19:32:59 ID:??? AAS
 <?php $s=(int)$_GET['s'];$d=array_map('intval',explode(' ', $_GET['d']));$n= 
 count($d);$m=max($d);$r=imagecreate($s,$s);imagecolorallocate($r,255,255,255); 
 $c=imagecolorallocate($r,128,128,128);$h=$s/2;for($i=0;$i<$n;$i++){$a=pi()*(2* 
 $i/$n-1/2);$t=$h*$d[$i]/$m;$p1[]=$h*(1+cos($a));$p1[]=$h*(1+sin($a));$p2[]=$h+ 
 $t*cos($a);$p2[]=$h+$t*sin($a);imageline($r,$h,$h,$p1[$i*2],$p1[$i*2+1],$c);} 
 imagepolygon($r,$p1,$n,$c);imagepolygon($r,$p2,$n,imagecolorallocate($r,0,0,255 
 ));header('Content-Type: image/gif');imagegif($r);?> 
  
 これはあまり安全じゃないよ。 
 フォーム作るゆとりなかったからアドレスバーの数字を直接いじってみて〜 
 外部リンク[php]:127.0.0.1 
407: nobodyさん [sage] 2006/03/14(火) 00:29:05 ID:??? AAS
 そのうち7行山田ウイルスとか出てきそうな予感 
408: nobodyさん [sage] 2006/03/15(水) 00:31:04 ID:??? AAS
 7行Webサーバができるなら山田もいけそうだな 
上下前次1-新書関写板覧索設栞歴
あと 44 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.019s