ソースフィルターなしDevel::Declare
のようなものを再実装しようとするように学習しようとしています。PDL::NiceSlice
スクリプトから次の行が削除されていることに気付いたとき、私はどこかに行きました。comment
説明するために、キーワードを使用してコードから行全体を削除し、その行に裸の単語がたくさんある場合でもコンパイルできる最小限の例を作成しました。
#Comment.pm
package Comment;
use strict;
use warnings;
use Devel::Declare ();
sub import {
my $class = shift;
my $caller = caller;
Devel::Declare->setup_for(
$caller,
{ comment => { const => \&parser } }
);
no strict 'refs';
*{$caller.'::comment'} = sub {};
}
sub parser {
#my $linestr = Devel::Declare::get_linestr;
#print $linestr;
Devel::Declare::set_linestr("");
}
1
と
#!/usr/bin/env perl
#test.pl
use strict;
use warnings;
use Comment;
comment stuff;
print "Print 1\n";
print "Print 2\n";
利回りのみ
Print 2
私は何が欠けていますか?
PS これを理解する必要がある場合は、おそらくさらにいくつかの質問があると思いますD::D
ので、事前に感謝します!