use strict;
use warnings;
use utf8;
binmode STDOUT, ":utf8";
use feature qw/say/;
use Encode 'decode';
use HTML::Entities;

my @ta_url =('https://w.atwiki.jp/swsw/pages/12.html','https://w.atwiki.jp/swsw/pages/15.html');

for my $ta_url (@ta_url){
my $syscommand = qx{curl -s $ta_url};
$ta_url = "";
my $body = decode('UTF-8',$syscommand);
undef($syscommand);
#________________________________________________

my $text = decode_entities($body);

$text =~ s/\<br\s\/\>/\n/g;

my @text_array = split(/\n/, $text);

my $flag1 = 0;
my $flag2 = 0;
my $text2 = "```perl\n";
my $length = @text_array; 

my $count = 0;
foreach(@text_array) {
  my $row = $_;

  if ($row =~ /noupdate_text/){
    $flag1 = 1;
  }
  unless ($flag1 == 1){
      next;
  }

  if ($row =~ /atwiki-lastmodify/){
    $flag2 = 1;
  }

  if ( $flag2 == 1){
    $text2 .= "```\n";
    last;
  }

  if ($count == 0){
      $count = 1;
      next;
  }
  $text2 .= "$row\n";
  $count ++;

}

say $text2;

}
Edit

Pub: 21 Sep 2022 13:08 UTC

Edit: 21 Sep 2022 16:44 UTC

Views: 546