"Steven M. Klass" wrote:
> 
> Hi all,
> 
>         Here is the general problem.  I have a file that I need to edit but can't.
> That file is then fed into another program.  Think of the file that I want to
> edit is like a makefile, that I want to use after I tweak it a bit.  The
> general idea would be:
> 1) Find out what needs to be edited in FILE - DONE
> 2) Open file and read in the contents.  While those are being read in compare
> the stuff to be edited looking for the flags.  I'm thinking some standard
> search and replaces? - DONE (I THINK:))
> 3)  Now after my edits have been inputed, how do I automatically invoke my
> app using this new "buffer"  - HELP!!
> 
> Here is what I think I need :
> 
> <snip>
> my $APP ="/bin/someapp"
> open (FILE, "file.txt") || die "Can't access file\n";
        ^^^^
Shouldn't this be CELL?

> while (<CELL>) {
>     s/INPUT\ FILE.*/INPUT\ FILE\ $VARIABLE/;
>         #replace the default with my option
>     }
> 
> $APP CELL &; #<<-- This is just a guess??  Basically disconnect and run?
> <snip>
> 
> Is this the right idea?  Is there a better way to do this??  Can someone
> complete this picture for me, I would really appreciate it


If I understand you correctly then this should work:

#!/usr/bin/perl -w
use strict;

my $app  = '/bin/someapp';
my $variable = 'something';

{
local $^I = '';  # edit in-place
local @ARGV = 'file.txt';

while ( <> ) {
    s/INPUT FILE.*/INPUT FILE $variable/;
    # replace the default with my option
    }
close ARGV; # just to be safe
}

system "$app $file &"; # Basically run in background

__END__


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to