SleepyDave has asked for the wisdom of the Perl Monks concerning the following question:
I just want to setup a basic scenario of what I would like to be able to do (hopefully armed with knowledge of how to do this, I can just build on that for what I hope to do later).
There are two scripts: Main.pl and Child.pl
Main.pl has a variable called $contents. $contents gets information added to it as the script goes along, such as html that will later get outputted. So lets say in Main.pl we have:
$content .= qq~ <table> <tr><td> This is table cell one </td><td> This is table cell two </td></tr> </table> ~;
Now, without changing that script at all, I would like to change the contents of the $contents variable using Child.pl.
When $contents contains:
<table> <tr><td> This is table cell one </td><td>
But has not yet added the second table cell, I would like Child.pl to insert:
This is an inserted table cell </td><td>
Into the $contents variable in Main.pl
-----
In scenario #2, let's say we have some code being executed in Main.pl, such as:
open(FILE, "myfile.txt");
@file = <FILE>;
close(FILE);
open(FILE, ">myfile.txt")
print FILE @file;
print FILE "New line of date";
print FILE "\n";
close(FILE);
Now, while that code is executing, I would like Child.pl to add another print statement into the code while it executes, but without actually changing the Main.pl file. So what I'm looking to do is after Main.pl executes the command:
print FILE "New line of date";
But before it executes:
print FILE "\n";
I want it to do another print statement specified in Child.pl:
print FILE " - additional info from Child.pl";
I hope what I'm trying to do makes sense, and hopefully there is a fairly simple (or at least understandable) solution. Thanks for all your help and support.
- Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Inserting one script's info into another script's output
by talexb (Chancellor) on Apr 28, 2002 at 03:35 UTC | |
|
Re: Inserting one script's info into another script's output
by Fletch (Bishop) on Apr 28, 2002 at 03:36 UTC | |
by SleepyDave (Initiate) on Apr 28, 2002 at 03:43 UTC | |
by chromatic (Archbishop) on Apr 28, 2002 at 04:22 UTC | |
by SleepyDave (Initiate) on Apr 28, 2002 at 05:11 UTC | |
by graff (Chancellor) on Apr 29, 2002 at 05:07 UTC |