Skip to content

Instantly share code, notes, and snippets.

@hirose31
Created Jun 12, 2020
Embed
What would you like to do?
#!/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