On Dec 23, 2003, at 1:03 AM, Ajey wrote: [..]
my @lines = `cat <2nd_script>`;
for each my $line (@lines) {
do something;
}
I guess this should work.I'm presuming that,"normal perl commands' means,
each perl stmt in the script. correct me incaes i'm wrong.
[..]

thanks for the Thump On the head![1]

What was I thinking when I saw the OP ask:

"I'm reading another perl script into array"

Why not use say a perl module??? One of our favorite
perl command - perldoc - is really little more than
a wrapper on Pod::Perldoc - quite literally:

        require 5;
        use Pod::Perldoc;
        BEGIN { $^W = 1 if $ENV{'PERLDOCDEBUG'} }
        exit( Pod::Perldoc->run() );

{ for the fun folks should then try
        perldoc -m perldoc
        perldoc -m Pod::Perldoc
}

Let's start with some basic definitions, that might
make this a bit more obvious:

        1. a script is a specific sequence of commands
                that may or may not take input and create output
                but should do something useful, that is run in
                a specific process space when invoked.

        2. a sub is a specific sequence of commands
                that may or may not take input and create output
                but should do something useful, that is run in
                the current process space when invoked.

3. a Perl Module is a way to cache subs for reuse.

        4. Refactoring Code - a process by which one takes
                already working code and make it slicker and cooler.

So let's start with a simple script 'foo.plx' that does
some basic stuff - it does basically everything that I
need it to do - but then I want to have a piece of code
'bar.plx' which will 'invoke' "foo.plx" to do some other stuff.

We all know about 'system()', and 'back ticks' and open(),
but what about abstracting the guts of foo.plx into the
Foo.pm so that we then simplify the original foo.plx to
be just like the perldoc???? you know, do some set up
stuff and then do

exit(Foo->do_cool(@arglist));

Now in our bar.plx we would want to have

        use Foo;
        ....

        my $got_back = Foo->do_cool(@arglist);
        # depending on what we $got_back do some
        # other stuff as well...

Just a thought to think about....

ciao
drieux

---

[1] the sound you are hearing is
the ringing of a hollow piece of wood!


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to