Backticks, qx(), but then it is usually discouraged, why call a program written in the same language by shelling out?
I think it's silly too, but I honestly don't know any better. So I looked up perlipc, and it's given me alot to think about but it hasn't exactly narrowed my options. Here is a rough outline of what I'm trying to do:
=> One perl script wanders through the directory tree and finds files suffixed with '.pro' and '.idl'.
It should pass these files to another perl script that:
=> Reformats the document headers for 'outline mode' as in 'EMACS outline mode.'
Then it prints the reformatted headers into standard out, where they are recieved by yet a third perl script that:
=> Takes anything formatted for outline mode and makes nice html tables or lists out of it.
The output of this script gets dumped into a file that is supposed to be a documentation web page. I have attached outline2html.pl in order to answer any questions about its operation - and if anybody wants to break it for me, I'd be happy for some criticism.
So now, here is my question - what is the right way to take a few different perl scripts and use them one inside the other, in such way that the output of one is the input of the next one?
- - -- \\ // -- --- \\ // --- ---- jason x ---- --- // \\ --- -- // \\ -- - -
#!/usr/bin/perl
#:#
#:# This code takes a document formatted
#:# for EMACS's outline mode and reformats
#:# it in html as either a definition list
#:# or a nested table.
#:#
# #
#:#
#:#:#:#:#
#:#:#:#:#:#
use Getopt::Long;
my %TBL = (
"head" => '<TABLE border=1>',
"section" => '<TR>'."\n".'<TD valign=top>',
"entry" => '<TD>',
"tail" => '</TABLE>'
);
my %DEF = (
"head" => '<DL>',
"section" => '<DT>',
"entry" => '<DD>',
"tail" => '</DL>'
);
my %STYLE;
my $flag = 'time for title';
## Option handling.
my $table; ## Use tabular format.
my $preformat; ## Preserve the spacing of the body text.
my $max_depth; ## Omit some headers.
GetOptions (
'table' => \$table,
'preformat' => \$preformat,
'max_depth=i' => \$max_depth
);
%STYLE = %DEF; ## Default.
%STYLE = %TBL if ($table);
#:#:#:#:#:#
#:#:#:#:#
#:#
# #
#:#
#:#:#:#:#
#:#:#:#:#:#
while (<>) {
## Translate Special Characters
s/</</;
s/>/>/;
## Mark up the title, the argument,
## the sections and the text.
if (/^[\/\w\s]+/) {
if ($flag eq 'time for title') {
print "<H1 align=center> ";
s/^\s+//;
s/\s+$//;
chomp;
print;
print "\n</H1>\n\n";
print "<hr noshade>\n\n";
$flag = 'time for arguments';
} elsif ($flag eq 'time for arguments') {
chomp;
print "<div align=center>\n";
print "\t<i> ";
s/^\s+//;
s/\s+$//;
chomp;
print;
print "\n\t</i>\n";
print "</div>\n\n";
} elsif (length($_) != 0) {
print "\t" x $last_depth unless($preformat);
print "$STYLE{entry}\t" unless($preformat);
print;
}
} elsif (s/^(\*+)//) {
$flag = 'time for normal text';
$this_depth = length($1);
unless (defined($max_depth) && $this_depth > $max_depth) {
if ($preformat) {
print "</PRE>\n" if (defined($last_depth));
}
$iterates = 1;
&partition;
$last_depth = length($1);
print "\t" x $last_depth;
print "$STYLE{section}\t";
print "<H3> ";
print;
print "\t" x ($last_depth+1);
print "</H3>\n";
print "$STYLE{entry} <PRE>\n" if ($preformat);
}
}
}
$this_depth = 0;
$iterates = 1;
&partition;
#:#:#:#:#:#
#:#:#:#:#
#:#
# #
#:#
#:#:#:#:#
#:#:#:#:#:#
## This subroutine keeps the beginnings
## and endings of the lists straight.
## Note that it expands empty parts in
## the list heirarchy.
sub partition {
&style;
if ($this_depth != $last_depth) {
$mu = ($last_depth-$this_depth)/abs($last_depth-$this_depth);
$this_depth += $mu;
$iterates++;
&partition;
}
}
## The chosen style is managed by
## this function.
sub style {
if ($this_depth > $last_depth) {
print "\t" x ($this_depth-1);
print "$STYLE{head}\n";
} elsif ($this_depth < $last_depth) {
print "\t" x ($last_depth-$iterates);
print "$STYLE{tail}\n";
}
}
#:#:#:#:#:#
#:#:#:#:#
#:#
#
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
