On Wednesday, April 24, 2002, at 07:18 , Tucker, Ernie wrote:

> When I put this in my script I get an error
>
> Name "main::NAME" used only once: possible typo at ubrstate2.pl line 521.
>
> Ernest P. Tucker II
[..]
Bart Proposed:
>
> open(NAME,"/path/to/perl_script.pl |");

as a way to run a perl script from inside another.

so let's look at the problem here.

the 'open' set the 'file handle' "NAME" to the
'popen(3)' "/path/to/perl_script.pl |" - which
you can then 'read' as if it were a 'file' of stuff.

but the error case says that this is the ONLY place
that you are using it - hence it really is only
used once - and it may actually have run.

The minimum bid:

        for all open(foo , ....)
        there must be one and only one matching close(foo)

So since your "/path/to/perl_script.pl |" 'ran'
but you did not read anything from it - you really
should do the decent thing and put a

        close(NAME);

If you wanted to 'read' the input - then you should
do the traditional

        while(<NAME>) {
                # read the input from our popen()
                # deal with it.
        }

ciao
drieux

---


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

Reply via email to