Dear Monks,

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.

Now i can put all headers like
use 5.010; use strict; use warnings; use Carp;
in a single header file called "header.pi" and put only one line of code
use Include 'header.pi'
instead of writing same lines to every file. I can also put my big sub to separate file and say
use Include 'agent.pi'
where it was originally.
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;
Nice to have some modern techniques in Perl - huh? I may send this to CPAN some day (if no one has not already done it).

Your comments are welcome.


In reply to Solved: splitting source file by AriSoft

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.