<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="ja" xmlns="http://www.w3.org/2005/Atom">
  <title>code&#12394;&#12395;&#12364;&#12375;: &#12459;&#12540;&#12489;&#12434;&#12471;&#12515;&#12483;&#12501;&#12523;&#12377;&#12427;</title>
  <link type="text/html" href="http://code.nanigac.com/source/view/534" rel="alternate"/>
  <link href="/favicon.ico" rel="icon"/>
  <updated>2008-06-17T16:55:17+09:00</updated>
  <author>
    <name>mikeda</name>
  </author>
  <entry>
    <title>1</title>
    <link type="text/html" href="http://code.nanigac.com/source/view/534?comment=1" rel="alternate"/>
    <author>
      <name>sion</name>
    </author>
    <updated>2008-06-17T14:05:21+09:00</updated>
    <summary>@cards &#12398;&#12487;&#12540;&#12479;&#12364; . &#28436;&#31639;&#23376;&#12391;&#25991;&#23383;&#21015;&#36899;&#32080;&#12391;&#12365;&#12289;&#12300;,&#12301;&#12434;&#21547;&#12414;&#12394;&#12356;&#12487;&#12540;&#12479;&#12394;&#12425;&#12381;&#12428;&#12418;&#33391;&#12356;&#12391;&#12377;&#12364;&#12289;&#37327;&#12364;&#22679;&#12360;&#12427;&#12392;&#12477;&#12540;&#12488;&#26178;&#12398; split &#12395;&#36000;&#33655;&#12364;&#12363;&#12363;&#12426;&#12289;s// &#12391;&#36899;&#32080;&#25991;&#23383;&#21015;&#12398;&#38500;&#22806;&#12392;&#12356;&#12358;&#12398;&#12418;&#12488;&#12522;&#12483;&#12461;&#12540;&#12394;&#27671;&#12364;&#12375;&#12414;&#12377;&#12290;

&#12381;&#12398;&#12450;&#12523;&#12468;&#12522;&#12474;&#12512;&#12398;&#12414;&#12414;&#12289;&#12418;&#12358;&#23569;&#12375;&#24037;&#22827;&#12377;&#12427;&#12392;&#12371;&#12435;&#12394;&#24863;&#12376;&#12391;&#12375;&#12423;&#12358;&#12363;&#12290;

#! /usr/bin/perl
use strict;

### @cards&#12399;1&#12363;&#12425;10&#12414;&#12391;&#12398;&#25968;&#20516;&#12398;&#37197;&#21015;
my @cards = (1..10);

### &#20803;&#12398;&#20516;&#12392;&#12289;&#20006;&#12409;&#26367;&#12360;&#29992;&#12398;&#12461;&#12540;&#65288;&#20081;&#25968;&#65289;&#12434;&#25345;&#12387;&#12383;&#12495;&#12483;&#12471;&#12517;&#12395;&#32622;&#12365;&#25563;&#12360;&#12414;&#12377;
$_ = {key =&gt; rand(), value =&gt; $_} for(@cards);

### &#20006;&#12409;&#26367;&#12360;&#29992;&#12398;&#12461;&#12540;&#12391;&#12477;&#12540;&#12488;&#12375;&#12414;&#12377;
@cards = sort {$a-&gt;{'key'} &lt;=&gt; $b-&gt;{'key'}} @cards;

### &#20803;&#12398;&#20516;&#12395;&#25147;&#12375;&#12414;&#12377;
$_ = $_-&gt;{'value'} for(@cards);

## &#32080;&#26524;&#12398;&#34920;&#31034;
print "$_\n" for (@cards);



&#21442;&#32771;&#12414;&#12391;&#12395;&#12289;&#12424;&#12367;&#12354;&#12427;&#27726;&#29992;&#12394;&#37197;&#21015;&#12398;&#12471;&#12515;&#12483;&#12501;&#12523;&#12399;&#12371;&#12435;&#12394;&#24863;&#12376;&#12376;&#12419;&#12394;&#12356;&#12391;&#12375;&#12423;&#12358;&#12363;&#65311;

#! /usr/bin/perl
use strict;

sub shuffle(@) {
    my @list = @_;
    my @ret = ();

    push(@ret, splice(@list, int(rand(scalar(@list))), 1)) while(@list);

    return @ret;
}


my @cards = (
    { name =&gt; 'AAA', value =&gt; '1' },
    { name =&gt; 'BBB', value =&gt; '2' },
    { name =&gt; 'CCC', value =&gt; '3' },
    { name =&gt; 'DDD', value =&gt; '4' },
    { name =&gt; 'EEE', value =&gt; '5' },
    { name =&gt; 'FFF', value =&gt; '6' },
    { name =&gt; 'GGG', value =&gt; '7' },
    { name =&gt; 'HHH', value =&gt; '8' },
    { name =&gt; 'III', value =&gt; '9' },
    { name =&gt; 'JJJ', value =&gt; '0' },
);

foreach my $item (shuffle @cards) {
    printf "[%s] - [%d]\n", $item-&gt;{'name'}, $item-&gt;{'value'};
}

</summary>
  </entry>
  <entry>
    <title>2</title>
    <link type="text/html" href="http://code.nanigac.com/source/view/534?comment=2" rel="alternate"/>
    <author>
      <name>mikeda</name>
    </author>
    <updated>2008-06-17T16:55:16+09:00</updated>
    <summary>&#12356;&#12365;&#12394;&#12426;&#12371;&#12435;&#12394;&#23436;&#29863;&#12394;&#36820;&#31572;&#12364;&#36820;&#12387;&#12390;&#12367;&#12427;&#12392;&#12399;ww
&#32032;&#26228;&#12425;&#12375;&#12356;&#12391;&#12377;&#12290;&#12415;&#12394;&#12373;&#12435;&#12393;&#12435;&#12393;&#12435;&#31227;&#26893;&#12375;&#12414;&#12375;&#12423;&#12358;&#12290;


&#12392;&#12426;&#12354;&#12360;&#12378;&#12495;&#12483;&#12471;&#12517;&#12420;&#12522;&#12501;&#12449;&#12524;&#12531;&#12473;&#12434;&#20351;&#12431;&#12378;&#31777;&#21336;&#12394;&#25991;&#23383;&#21015;&#20966;&#29702;&#12391;&#12289;&#12392;&#26360;&#12365;&#12414;&#12375;&#12383;&#12290;
&#24403;&#28982;&#12289;&#27726;&#29992;&#24615;&#12434;&#32771;&#12360;&#12428;&#12400;&#12477;&#12540;&#12488;&#12377;&#12409;&#12365;&#12399;&#20516;&#12391;&#12399;&#12394;&#12367;&#21442;&#29031;&#12391;&#12377;&#12290;
split&#20351;&#12387;&#12383;&#12426;&#27491;&#35215;&#34920;&#29694;&#20351;&#12387;&#12383;&#12426;&#12398;&#12509;&#12522;&#12471;&#12540;&#12398;&#19981;&#19968;&#33268;&#12399;&#12431;&#12363;&#12426;&#12420;&#12377;&#12373;&#37325;&#35222;&#21322;&#20998;&#12289;&#12493;&#12479;&#21322;&#20998;&#12391;&#12377;ww
&#12475;&#12497;&#12524;&#12540;&#12479;&#12434;&#21547;&#12416;&#25991;&#23383;&#21015;&#21839;&#38988;&#12418;&#12289;split&#12398;&#28155;&#23383;&#24037;&#22827;&#12375;&#12383;&#12426;&#27491;&#35215;&#34920;&#29694;&#12398;&#37327;&#25351;&#23450;&#23376;&#20351;&#12387;&#12383;&#12426;&#12399;&#12392;&#12426;&#12354;&#12360;&#12378;&#30465;&#30053;&#12375;&#12390;&#21453;&#24540;&#24453;&#12385;&#12391;w



&#12375;&#12363;&#12375;&#12356;&#12365;&#12394;&#12426;&#33258;&#20998;&#12524;&#12505;&#12523;&#12391;&#12399;&#23436;&#29863;&#12392;&#24605;&#12360;&#12427;&#12467;&#12540;&#12489;&#12364;&#36820;&#12387;&#12390;&#12365;&#12383;&#12398;&#12391;&#12414;&#12392;&#12418;&#12394;&#12362;&#36820;&#12375;&#12467;&#12540;&#12489;&#12364;&#12377;&#12368;&#12395;&#24605;&#12356;&#12388;&#12363;&#12394;&#12356;&#12539;&#12539;&#12539;
&#12392;&#12356;&#12358;&#12431;&#12369;&#12391;&#20197;&#19979;&#12289;perl&#12395;&#38480;&#12387;&#12383;&#12493;&#12479;&#12467;&#12540;&#12489;&#12289;&#12424;&#12356;&#12371;&#12398;&#12415;&#12394;&#12373;&#12435;&#12399;&#32118;&#23550;&#12510;&#12493;&#12375;&#12394;&#12356;&#12424;&#12358;&#12395;

### &#26411;&#23614;&#12376;&#12419;&#12394;&#12367;&#12390;&#12450;&#12479;&#12510;&#12395;&#20081;&#25968;&#12388;&#12369;&#12428;&#12400;split&#12418;&#12356;&#12425;&#12394;&#12356;&#25163;&#25244;&#12365;&#12467;&#12540;&#12489;
my @cards = (1..10);

$_ =  rand() . ",$_" for(@cards);
@cards = sort @cards;
$_ =~ s/^.*?,// for(@cards);

print "$_\n" for (@cards);


### &#20081;&#25968;&#12399;&#12363;&#12406;&#12387;&#12383;&#12426;&#12375;&#12394;&#12356;&#12384;&#12429;&#12358;&#24605;&#24819;&#12395;&#22522;&#12389;&#12356;&#12383;&#20081;&#25968;&#12434;&#12461;&#12540;&#12395;&#12495;&#12483;&#12471;&#12517;&#12434;&#20316;&#12427;&#25163;&#25244;&#12365;&#12467;&#12540;&#12489;
my @cards = (1..10);

my %hash = map {(rand, $_)} @cards;
@cards = @hash{sort keys %hash};

print "$_\n" for (@cards);


### &#12373;&#12425;&#12395;&#12495;&#12483;&#12471;&#12517;&#38306;&#25968;&#12394;&#12435;&#12390;&#20081;&#25968;&#12415;&#12383;&#12356;&#12394;&#12418;&#12398;&#12384;&#12429;&#12358;&#24605;&#24819;&#12395;&#22522;&#12389;&#12356;&#12383;&#12402;&#12393;&#12356;&#25163;&#25244;&#12365;&#12467;&#12540;&#12489;&#65288;&#27598;&#22238;&#21516;&#12376;&#20006;&#12403;&gt;&lt;&#65289;
my @cards = (1..10);

@hash{@cards} = ();
print "$_\n" for (keys %hash);

</summary>
  </entry>
</feed>
