Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Compiling and executing multiple files.

by valavanp (Curate)
on Aug 30, 2006 at 09:10 UTC ( #570340=note: print w/ replies, xml ) Need Help??


in reply to Re: Compiling and executing multiple files.
in thread Compiling and executing multiple files.

Yes all files are perl source. I am running it on SUSE linux OS. The solution which chargrill given is in shell prompt. Is there any way i can do it inside a perl script. Please regret me if i am wrong it's just a suggestion. Also when i execute the below code: for i in '*.pl'; do perl -c $i>$i.log 2>&1; echo "compiled, now running" >> $i.log; perl $i >> $i.log 2>&1;done I am getting the result for only one file not for other filees.


Comment on Re^2: Compiling and executing multiple files.
Re^3: Compiling and executing multiple files.
by cdarke (Prior) on Aug 30, 2006 at 10:06 UTC
    Of course (BTW, you put single quotes around *.pl, which won't expand to filenames in the shell). TMTOWTDI, and the elegant way would be to redirect STDOUT and STDERR in Perl, and use fork/exec, but I guess you do not want to go that far. Simplistically it is not all that different from shell:
    for my $script glob('*.pl') { system ("perl $script>$script.log 2>&1"); }

    I havn't done a separate compile phase, chargrill showed how to do that if you need it. I am 'cheating' by allowing the shell to do the redirection, which purists will not like, but it is simpler this way.
    You can programatically pick up the exit value from the call by testing the return value from system(), or $? (die returns 255 or the last value of $!).

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (16)
As of 2014-12-18 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (58 votes), past polls