7͂̃TvR[h
---------------------
ڎiy[Wԍj
P142-1
P142-2
P143
P144
P145
P148
P149
P150
P151
P156
P157
P158
P162-1
P162-2
P163-1
P163-2
P163-3
P164-1
P164-2
P165
P168
P169
P170
---------------------

P142-1
# helloTu[`̌Ăяo
#  hello.pl

# Tu[`Ăяo
&hello( );

# Tu[`̒`
sub hello {
  print "ɂ́A̓Tu[`łB\n";
}

P142-2
# hello_argTu[`̌Ăяo
#  hello_arg.pl

# Tu[`Ăяo
&hello_arg("Y");

# Tu[`̒`
sub hello_arg {
  my($name) = @_;
  print "ɂ́A$namełB\n";
}

P143
# ߂lhello_retTu[`̌Ăяo
#  hello_ret.pl

# Tu[`Ăяo
$string = &hello_ret("Ԏq");

# ߂l\
print "߂l: $string";

# Tu[`̒`
sub hello_ret {
  my($name) = @_;
  # Ԃ
  "ɂ́A$namełB\n";
}

P144
# return֐gĖ߂lԂ
#  hello_return.pl

# Tu[`Ăяo
$string = &hello_return("Ԏq");

# ߂l\
print "߂l: $string";

# Tu[`̒`
sub hello_return {
  my($name) = @_;
  # Ԃ
  return("ɂ́A$namełB\n");
}

P145
# nmC̓
#  hanoi.pl

# Tu[`Ăяo
&hanoi(3, "", "", "E");

# Tu[`{
sub hanoi {
  my($disk, $bar1, $bar2, $bar3) = @_;
  
  # ~Ղ1ȏcĂ
  if ($disk > 0) {
    # ċAĂяo1
    hanoi($disk - 1, $bar1, $bar3, $bar2);
    
    # ړe\
    print "~ $disk  $bar1 ̖_ $bar2 ̖_ɈړB\n";
    
    # ċAĂяo2
    hanoi($disk - 1, $bar3, $bar2, $bar1);
  }
}

P148
# localmỹeXg
#  local_my.pl

# Tu[`Ăяo
&local_my( );

# Tu[`{
sub local_my {
  # localɂ`
  local($local_value) = "Y";

  # myɂ`
  my($my_value) = "Ԏq";

  # ʃTu[`Ăяo
  &echo_local_my( );
}

# Tu[`Ăяoʃ[`
sub echo_local_my {
  # localmy̒l\
  print "localɂl: $local_value\n";
  print "myɂl: $my_value\n";
}

P149
# localŒ`ꂽϐ̒lύX
#  modify_local.pl

# Tu[`Ăяo
&modify_local( );

# Tu[`{
sub modify_local {
  # [JŒ`
  local($local_value) = "̃eLXg";
  # [JŒ`
  my($my_value) = "̃eLXg";

  print "[sO]\n";
  print "local:\t$local_value\n";

  print "my:\t$my_value\n";

  &change_local( );

  print "[s]\n";
  print "local:\t$local_value\n";
  print "my:\t$my_value\n";
}

sub change_local {
  $local_value = "ύX܂B";
  $my_value = "ύX܂B";
}

P150
# ubNł̃[Jϐ̒`
#  block.pl

$variable = "O[o";

print "Tu[`sO: $variable\n";

# Tu[`Ăяo
&block( );
print "Tu[`s: $variable\n";

# Tu[`{
sub block {
  my($variable) = "[J";
  print "\tubNO: $variable\n";
  {
    my($variable) = "ubN";
    print "\t\tubN: $variable\n";
  }
  print "\tubN: $variable\n";
}

P151
# ourmỹeXg
#  our_scope.pl

# O[oϐ錾
@global_value = (1, 2, 3);

&modify_my( );
print "[my] ", @global_value, "\n";

&modify_our( );
print "[our] ", @global_value, "\n";

# myɂO[oϐ̏㏑
sub modify_my {
  my(@global_value);
  print "[my] ", @global_value, "\n";
  @global_value = ("A", "B", "C");
  print "[myύX] ", @global_value, "\n";
}

# ourɂO[oϐ̏㏑
sub modify_our {
  our(@global_value);
  print "[our] ", @global_value, "\n";
  @global_value = ("A", "B", "C");
  print "[ourύX] ", @global_value, "\n";
}

P156
# XJ[ϐ̃t@X
#  reference.pl

$string = "͑YłB";

# Tu[`sO
print "sO: $string\n";

# t@XnăTu[`s
&sub_reference(\$string);

# Tu[`s
print "s: $string\n";

# Tu[`
sub sub_reference {
  # t@X󂯂
  my($reference) = @_;

  # t@X̃XJ[ϐ̓eύX
  $$reference =~ s/Y/Ԏq/;
}

P157
# z̃t@X
#  reference_array.pl

@array = (1 .. 5);

# Tu[`sO
print "sO: ", join(", ", @array), "\n";

# t@XnăTu[`s
&sub_reference_array(\@array);

# Tu[`s
print "s: ", join(", ", @array), "\n";

# Tu[`
sub sub_reference_array {
  # t@X󂯂
  my($reference_array) = @_;

  # t@X̔z̓eύX
  for ($i = 0; $i < @$reference_array; $i++) {
    $$reference_array[$i]++;
  }
}

P158
# Tu[`Ŗ߂l𒼐ڎ擾
#  hello_anonymous.pl

# Tu[`
$string = sub {
  # Ԃ
  return("ɂ́A$namełB\n");
};

# ߂l\
$name = "Ԏq";
print "߂l: ", &$string;

P162-1
# helloCu
#  hello_lib.pl

# Tu[``
sub hello {
  my($name) = @_;
  print "ɂ́A$nameB\n";
}

# ߂l
1;

P162-2
# hello_lib̌Ăяo
#  hello_call.pl

# CǔĂяo
require("hello_lib.pl");

# Tu[`̌Ăяo
&hello("Y");

P163-1
# ݒt@Cǂݍ
#  config_load.pl

# l
$name = "";

# t@C̑݃`FbN
if (-r "config") {
  require("config");
}

print "ɂ́A$nameB\n";

P163-2
# ݒt@C
#  config

$name = "Y";
1;

P163-3
# BEGINEND̃eXg
#  begin_end.pm

# BEGIN[`
BEGIN {
  print "W[Jn܂B\n";
}

# END[`
END {
  print "W[I܂B\n";
}

1;

P164-1
# begin_endW[ǂݍ
#  begin_end_call.pl

print "W[ĂяoO\n";

# W[Ăяo
use begin_end;
print "C[`̏I\n";

P164-2
# pbP[WhelloW[
#  hello_package.pm

# helloƂOŃpbP[W`
package hello;

# ̃Tu[`hello::helloƂČĂяo
sub hello {
  my($name) = @_;
  print "ɂ́A$nameB\n";
}

1;

P165
# hello_packageĂяo
#  hello_package_call.pl

# pbP[WĂяo
use hello_package;

# pbP[WtɌĂяo
&hello("Y");

# pbP[WtČĂяo
&hello::hello("Y");

# ̃Tu[``
sub hello {
  my($name) = @_;
  print "悤ȂA$nameB\n";
}

P168
# File::Copygăt@CRs[
#  copy.pl

# W[Ăяo
use File::Copy;

if (@ARGV != 2) {
  # 2ȊÔƂɂ͎g\
  &usage( );
}

# W[̃[`s
copy($ARGV[0], $ARGV[1]);

print "Rs[ɃG[܂($!)B\n" if ($!);

# g\
sub usage {
  print <<EOT
copy.pl: t@C̃Rs[

 copy.pl Rs[t@C  Rs[t@C
EOT
  ;
  exit(1);
}

P169
# x`}[N
#  benchmark.pl

# W[Ăяo
use Benchmark;

# 1ڂ̃x`}[NIuWFNg
$before_time = new Benchmark;

# 50000JEǧvZ
&recursive(50000);

# 2ڂ̃x`}[NIuWFNg
$after_time = new Benchmark;

# 2̃x`}[N猋ʂ߂
$diff = timediff($after_time, $before_time);

# \
print ": ", timestr($diff), "\n";

# Ԃv邽߂̍ċAĂяo
sub recursive {
  my($number) = @_;

  # 1JE^炵0ɂȂ܂ōċAĂяos
  &recursive(--$number) if ($number);
}

P170
# UTF-8̕ϐg
#  utf8_consumption_duty.pl

# W[Ăяo
use utf8;

$ŗ = 0.05;

print "subtotal: ";

$vz = <STDIN>;
chomp($vz);

$Ŋz = $vz * $ŗ;

$vz = $vz + $Ŋz;

print "tax: ${Ŋz} yen\n";
print "total amount: ${vz} yen\n";
