======================================================================
 Perl7::Handy áá»ááºáá¾ááºá¸áááºá¸áá½á¾ááº [MY] áá¼ááºáá¬áá¬áá¬
======================================================================

[ 1. Installation ]

  ááá·áºáá½ááºá¸áá«:
    cpan Perl7::Handy

  script áá½ááºá¡áá¯á¶á¸áá¼á¯áá«:
    use Perl7::Handy;

  á¡áá»á­á¯á¸áááºáá±á¬ááºáá¾á¯ (Perl 5.010001 áá¾áá·áºá¡áááº):
    * use strict               -- variable áá¼á±áá¬áá»ááºáá­á¯áá½ááºáá¬á¸áááº
    * use warnings             -- ááá­áá±á¸áá»ááºáá»á¬á¸áá­á¯áá½áá·áºáááº
    * no bareword::filehandles -- open(FILE,...) áá¯á¶áá¶áá­á¯áá¼ááºá¸áááºáááº
    * no multidimensional      -- $hash{a,b} á¡áá¯áá°áá¾á¯áá­á¯áá­ááºáááº
    * use feature qw(signatures)  (Perl 5.020+)
    * no feature qw(indirect)     (Perl 5.031009+)

  á¡áá»á­á¯á¸áááºáá±á¬ááºáá¾á¯ (Perl 5.005_03 -- 5.008):
    * use strict
    * open/opendir/sysopen/pipe/socket/accept autovivification
    # socket() မအောင်မြင်သောအခါ autodie မဖြစ် (void context တွင် false ကိုသာ ပြန်ပေးသည်)
    * tie á¡áá¼á±áá¶ $; áá»á±á¬ááºáá½ááº (áá¼áá·áºáá¬á¸áá±á¬áá¼á­á¯á¸áá® array á¡áá¯áá°áá¾á¯áá¬á¸áá®á¸)

[ 2. open() -- autovivification ]

  my $fh;
  open($fh, "< file.txt");   # áááºáá«
  open($fh, "> file.txt");   # áá±á¸áá« (override)
  open($fh, ">> file.txt");  # áááºáá¼áá·áºáá«
  open($fh, "+< file.txt");  # áááº/áá±á¸
  while (my $line = readline($fh)) { ... }
  print $fh "text\n";
  close($fh);

  # bareword handle áá­á¯áá¼ááºá¸áááºáááº:
  open(FILE, "< file.txt");   # dies: Use of bareword handle in open

[ 3. open() -- 3-arg ]

  my $fh;
  open($fh, '<',  "file.txt");   # áááºáá«
  open($fh, '>',  "file.txt");   # áá±á¸áá« (override)
  open($fh, '>>', "file.txt");   # áááºáá¼áá·áºáá«
  open($fh, '+<', "file.txt");   # áááº/áá±á¸
  open($fh, '+>', "file.txt");   # áááº/áá±á¸ (override)
  open($fh, '-|', "cmd");        # command pipe áá¾áááºáá«
  open($fh, '|-', "cmd");        # command pipe áá­á¯á·áá±á¸áá«

[ 4. opendir() / sysopen() ]

  my $dh;
  opendir($dh, "/path/to/dir");
  while (my $e = readdir($dh)) {
      next if $e eq '.' or $e eq '..';
      print "$e\n";
  }
  closedir($dh);

  use Fcntl qw(O_RDONLY O_WRONLY O_CREAT O_TRUNC);
  my $fh;
  sysopen($fh, "file.txt", O_RDONLY);
  sysopen($fh, "file.txt", O_WRONLY | O_CREAT | O_TRUNC, 0644);

[ 5. pipe() ]

  my($reader, $writer);
  pipe($reader, $writer);
  if (my $pid = fork()) {
      close($writer);
      while (my $line = readline($reader)) { print $line }
      close($reader);
  } else {
      close($reader);
      print $writer "child process áá¾ áááºá¹ááá¬áá«\n";
      close($writer);
      exit 0;
  }

[ 6. socket() / accept() ]

  use Socket qw(AF_INET SOCK_STREAM sockaddr_in inet_aton);
  my $server;
  socket($server, AF_INET, SOCK_STREAM, 0);
  # မှတ်ချက်: socket() မအောင်မြင်သောအခါ autodie မဖြစ်; return value ကို စစ်ဆေးပါ။
  my $client;
  accept($client, $server);

[ 7. no bareword::filehandles ]

  # bareword handle áá­á¯áá¼ááºá¸áááºáááº:
  open(FILE, "< file.txt");    # error: Bareword filehandle
  print FILE "hello\n";        # error: Bareword filehandle

  # lexical variable áá¯á¶á¸áá«:
  my $fh;
  open($fh, "< file.txt");
  print $fh "hello\n";
  close($fh);

[ 8. no multidimensional ]

  # áá¼áá·áºáá¬á¸áá±á¬áá¼á­á¯á¸áá® hash á¡áá¯áá°áá¾á¯áá­ááºáááº:
  my %h;
  $h{1,2} = "val";    # error: Use of multidimensional array emulation

  # áááºáá¾á¬á¸áá±á¬áá±á¬á·áá­á¯áá¯á¶á¸áá«:
  $h{"$x,$y"} = "val";

[ 9. Signatures (Perl 5.020+) ]

  # signature á¡áá­á¯á¡áá»á±á¬ááºáá½áá·áºáááº; áááºá¸áááºáá¾á¯ááá­áá±á¸áá»ááºáá­ááºáá­ááºáááº
  use Perl7::Handy;

  sub greet($name) { return "Hello, $name!" }
  sub add($x, $y)  { return $x + $y }

[ 10. no indirect (Perl 5.031009+) ]

  # áá½ááºáá­á¯ááºáá±á¬object syntax áá­ááºáááº:
  my $obj = new MyClass;   # error: indirect syntax

  # áá­á¯ááºáá±á¬ááºáá¬ syntax áá¯á¶á¸áá«:
  my $obj = MyClass->new;

[ 11. CVE-2016-1238 ]

  # Perl7::Handy áááºááááºáá»á­ááºáá½ááº @INC áá¾ áááºáá¾á­ directory áá­á¯áááºáá¾á¬á¸áááºá
  # BEGIN { pop @INC if $INC[-1] eq '.' }

[ 12. áá¬á¸áá¾ááºá¸á¡á¬á¸áá¼áá·áºáá¯ááºáá±á¬ááºáá­á¯ááºáá¾á¯ááá¬á¸ ]

  Feature              5.005_03  5.006-009  5.010+  5.020+  5.031009+
  -------------------  --------  ---------  ------  ------  ---------
  strict               yes       yes        yes     yes     yes
  warnings             no        yes        yes     yes     yes
  autovivif. open()    yes       yes        yes*    yes*    yes*
  no bareword FH       emulated  emulated   yes     yes     yes
  no multidim.         tie       tie        yes     yes     yes
  signatures           no        no         no      yes     yes
  no indirect          no        no         no      no      yes

[ 13. Official resources ]

  Perl7::Handy (MetaCPAN):
    https://metacpan.org/dist/Perl7-Handy

  bareword::filehandles:
    https://metacpan.org/dist/bareword-filehandles

  INABA Hitoshi (ina) on CPAN:
    https://metacpan.org/author/INA

======================================================================
