Skip to content

Instantly share code, notes, and snippets.

@hirose31
Created June 12, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirose31/bfe123d4e763627bcca739c447e8bf65 to your computer and use it in GitHub Desktop.
Save hirose31/bfe123d4e763627bcca739c447e8bf65 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use 5.010_000;
use Data::Dumper;
# https://perldoc.jp/docs/perl/5.26.1/perlvar.pod
# <FH>, readline, readdir, each が単独で while テストで テストされた場合の、次の値や入力レコードを入れるデフォルトの場所。 while テスト以外ではこれは起こりません。
sub foo {
my %h = ( foo => 1 );
while (each %h) {}
# open my $fh, '<', '/etc/passwd' or die $!;
# while (<$fh>) {}
# close $fh;
return 1;
}
my $aaa = ['31'];
@$aaa = grep { foo() } @$aaa;
print Dumper $aaa; # => [ undef ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment