Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How to display the .pl process in command line

by bms (Monk)
on Mar 27, 2012 at 07:47 UTC ( #961868=note: print w/replies, xml ) Need Help??


in reply to How to display the .pl process in command line

Well, I have a couple recommendations. For one, please organize your code. Remember DRY(Don't Repeat Yourself), there is a lot of code duplication in that snippet. And also think about logically grouping your code. Secondly(and most importantly), I think you want IO::Tee.

use IO::Tee; my $out_handles = new IO::Tee(\*STDOUT, new IO::File('>random_file.txt +')); print $out_handles "*Hey Buddy*\n"; print $out_handles "*I'm on your screen and your file!*\n";

So, essentially, IO::Tee allows you to write to multiple file handles simultaneously.

You could use a second print statement with just a string to accomplish the same result. Or select. Plus a bunch I can't think of right now. Always a lot of choices.

Replies are listed 'Best First'.
Re^2: How to display the .pl process in command line
by astronogun (Sexton) on Mar 27, 2012 at 09:08 UTC
    it failed.. I download the IO::File at cpan then when i run the command it said that Can't locate object method "new" via package "IP::File (perhaps you forgot to load "IP::File"?) the i add use IP::File then it said that can' locate IP/File.pm then I checked cpan for download there's no IP::File.. did do it incorrectly? Thanks
      IO::File and IO::Tee. Not sure what IP::File is, looks like a typo. You may have to 'use IO::File'. It is a core module.
        Hmm how about this? I want it to make it simpler... After running the script (the one I posted above) it will display "Ok" or if it's failed it will display an error message.. I'm reading regarding STDIN, STDOUT and STDERR.. but I'm having hard time understanding... Any ideas?

        Hmm how about this? I want it to make it simpler... After running the script (the one I posted above) it will display "Ok" or if it's failed it will display an error message.. I'm reading regarding STDIN, STDOUT and STDERR.. but I'm having hard time understanding... Any ideas?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961868]
help
Chatterbox?
[LanX]: ... so my boss started a project with the newest sun servers and invited the traders to come on weekend to test it... and they were so pleased, that they forced him to keep it in production...
[ambrus]: Corion: sure, this is the long-term plan. The short term is that I have to run this ungodly mess to get results from the new input data today.
[Corion]: ambrus: Most of our "automation" is tied to process exit codes and a shell pipeline :-\
[LanX]: ... a week later they realized that one of the databases - which recorded how much the other banks due to this bank - was not correctly plugged
[ambrus]: Corion: I have no problem with exit codes and shell pipeline. My problem is that the current process requires a lot of manual intervention from me, including editing the source codes.
[ambrus]: (Also a lot of manual intervention by two or three other co-workers, who do other parts of the process.)
[ambrus]: Some of the manual part is unavoidable, but not all.
[choroba]: LanX was there a way to recover the numbers from the remaining information?
[Corion]: LanX: Ow ;)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2017-03-29 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.