AriSoft has asked for the wisdom of the Perl Monks concerning the following question:
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Solved: splitting source file
by ambrus (Abbot) on Feb 22, 2010 at 13:18 UTC | |
|
Re: Solved: splitting source file
by cdarke (Prior) on Feb 22, 2010 at 14:27 UTC | |
|
Re: Solved: splitting source file
by ww (Archbishop) on Feb 22, 2010 at 13:46 UTC | |
|
Re: Solved: splitting source file
by chromatic (Archbishop) on Feb 22, 2010 at 22:31 UTC | |
by AriSoft (Sexton) on Feb 23, 2010 at 05:42 UTC | |
by chromatic (Archbishop) on Feb 23, 2010 at 18:56 UTC | |
|
Re: Solved: splitting source file
by cdarke (Prior) on Feb 22, 2010 at 15:28 UTC |