I solved my earlier split file problem by creating a new module as you suggested. This module is called "Include" and it works exacly like #include works in C.
in a single header file called "header.pi" and put only one line of codeuse 5.010; use strict; use warnings; use Carp;
instead of writing same lines to every file. I can also put my big sub to separate file and sayuse Include 'header.pi'
where it was originally.use Include 'agent.pi'
package Include; use 5.010; use strict; use warnings; use Carp; use Filter::Util::Call; sub import { my (undef, @files) = @_; my (undef, $origin, $line) = caller; filter_add sub { filter_del(); while (defined (my $file = shift(@files))) { $_ .= "\n# line 1 $file\n"; local $/; undef $!; unless (open FH, "<", $file and $_ .= <FH> and !$!) { carp "Can not include '$file':$!"; return -1; } close FH; } ++$line; $_ .= "\n# line $line $origin\n"; return 1; }; } 1;
Your comments are welcome.
In reply to Solved: splitting source file by AriSoft
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |