Perlã§HTMLã®ç¹°ãè¿ãé¨åãã¤ã³ã¯ãªã¡ã³ããã¦ã¿ã
HTMLã®æ§ç¯ã¨ããã¦ãã¨ããããç¹°ãè¿ãé¨åãå¤ãã
ã§ãç»åãã¡ã¤ã«ã ãå·®ãæ¿ãã¦ã¿ãããªã
ç§ã¯ã好ã¿çã«ç»åãã¡ã¤ã«åããããã¡ã¤ã«åãï¼é£çªãã«ãã¦ããã®ã§ã
ããã¯ãèªååã§ããããããªããã¨æã£ãã
ã¯ããã¯ãEmacsã¨ããã¥ã¼ã³ã§ããããã¹ãã¨ãã£ã¿ã使ããã
ãªãã¦ãã¨ãèãããLispãè¦ããã幸ãã«ãªãããã ãã
ããããããããèããã¨Perlã¯ããã¹ãã®ç·¨éã«å¼·ã¿ãæã£ã¦ããã®ãç¹å¾´ã ã£ãã
ãPerl使ããªããã¨ããããPerlã§è§£æ±ºããªããã
ãããªå£°ãããæ°ãããã®ã§ãPerlã¹ã¯ãªãããæ¸ãã¦ã¿ãã
ç¾ããããªãã¨ããªãã¹ã¯ãªããã ããä¸æ¯ãªã³ãããã解æ¾ãããã
#!/usr/bin/perl # # ç¹å®ã®ä½ç½®ã«ã¤ã³ã¯ãªã¡ã³ãæ°åãå ¥ãã¦ãã£ã¦HTMLæ§ç¯ãç縮åããã¹ã¯ãªãã # 3ã¤ãã¤ã®<div class="unit">ã<div class="three_unit clearfix">ã§ããããã¨ããã®ãç¹°ãè¿ã # 20101230by_perl48 use strict; use warnings; use encoding qw(shiftjis); # ç¹°ãè¿ãåæ°ãæå®ãã my $max = 24; # ãã¡ã¤ã«ãã³ãã«ããªã¼ãã³ãã¦ãå¤é¨ããã¹ããã¡ã¤ã«ã¸ã®æ¸ãè¾¼ã¿æºå open my $writing, '>>', "dekiagari.txt"; for( my $i = 1; $i <= $max; $i ++ ){ # 1çªç®ã4çªç®ã7çªç®ï½¥ï½¥ï½¥ã«<div class="three_unit clearfix">ãçªã£è¾¼ã if( $i % 3 == 1 ){ print $writing <<END_HEADER; <div class="three_unit clearfix"> END_HEADER } # <div class="unit">å ã®ç»åãã¡ã¤ã«åæ«å°¾ãã¤ã³ã¯ãªã¡ã³ããã¦è¤è£½ãã¦ãã print $writing <<END_OF_UNIT; <div class="unit"> <a href="/img/sem_pho2010-$i.jpg" rel="lightbox"><img src="/img/sem_pho2010-$i.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> END_OF_UNIT # 3çªç®ã6çªç®ã9çªç®ï½¥ï½¥ï½¥ã«</div>ãçªã£è¾¼ã if( $i % 3 == 0 ){ print $writing <<END_FOOTER; </div> END_FOOTER } }
ã§ãdekiagari.txt ã«åºåãããã®ãä¸
<div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-1.jpg" rel="lightbox"><img src="/img/sem_pho2010-1.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-2.jpg" rel="lightbox"><img src="/img/sem_pho2010-2.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-3.jpg" rel="lightbox"><img src="/img/sem_pho2010-3.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-4.jpg" rel="lightbox"><img src="/img/sem_pho2010-4.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-5.jpg" rel="lightbox"><img src="/img/sem_pho2010-5.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-6.jpg" rel="lightbox"><img src="/img/sem_pho2010-6.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-7.jpg" rel="lightbox"><img src="/img/sem_pho2010-7.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-8.jpg" rel="lightbox"><img src="/img/sem_pho2010-8.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-9.jpg" rel="lightbox"><img src="/img/sem_pho2010-9.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-10.jpg" rel="lightbox"><img src="/img/sem_pho2010-10.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-11.jpg" rel="lightbox"><img src="/img/sem_pho2010-11.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-12.jpg" rel="lightbox"><img src="/img/sem_pho2010-12.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-13.jpg" rel="lightbox"><img src="/img/sem_pho2010-13.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-14.jpg" rel="lightbox"><img src="/img/sem_pho2010-14.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-15.jpg" rel="lightbox"><img src="/img/sem_pho2010-15.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-16.jpg" rel="lightbox"><img src="/img/sem_pho2010-16.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-17.jpg" rel="lightbox"><img src="/img/sem_pho2010-17.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-18.jpg" rel="lightbox"><img src="/img/sem_pho2010-18.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-19.jpg" rel="lightbox"><img src="/img/sem_pho2010-19.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-20.jpg" rel="lightbox"><img src="/img/sem_pho2010-20.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-21.jpg" rel="lightbox"><img src="/img/sem_pho2010-21.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div> <div class="three_unit clearfix"> <div class="unit"> <a href="/img/sem_pho2010-22.jpg" rel="lightbox"><img src="/img/sem_pho2010-22.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-23.jpg" rel="lightbox"><img src="/img/sem_pho2010-23.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> <div class="unit"> <a href="/img/sem_pho2010-24.jpg" rel="lightbox"><img src="/img/sem_pho2010-24.jpg" width="200" alt="" rel="lightbox[seminor]" /></a> <p>text</p> </div> </div>