Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Variable possession after script death

by Mur (Pilgrim)
on Aug 08, 2003 at 15:50 UTC ( #282228=snippet: print w/replies, xml ) Need Help??
Description: I had a need for functionality I'd written in a stand-alone script. The script read two different databases for the corresponding table, and compared the rows, burping out the primary key of the rows which were identical. But it did so in the form of a formatted report. I really didn't want to rewrite the script to produce a parseable output, nor did I want to write the new script to parse the report. So I had the new script require the old one, and "possess" its variables beyond the grave...
use vars '@keywords';

my $h = select(*NULL);

# This script leaves all its results in @keywords,
# and writes a flowery report that we ignore.
require '';

# and @keywords has all the stuff we want.
Replies are listed 'Best First'.
Re: Variable possession after script death
by Aristotle (Chancellor) on Aug 10, 2003 at 16:54 UTC
    Hmm. How about rewriting the old script so that it consists of one portion that does the work and produces @keywords and another that prints a report? The first part could then be used by both scripts - either as a full blown locally installed module or as a file that's simply required.

    It's always a good idea to separate logic from output, even when you're not creating webpages. *grin*

    Makeshifts last the longest.

Re: Variable possession after script death
by RMGir (Prior) on Aug 08, 2003 at 16:30 UTC

    What a hack.

    What a GREAT hack. :)

    I don't need this trick myself at the moment, but I'm going to try to remember it...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://282228]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2020-09-29 03:55 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (145 votes). Check out past polls.