Ok, so I'm not *really* a beginner; however, wondering if this is
possible....

I have a subroutine that basically goes through an array and searches
for processes... It has two different types of processes it looks for,
so I just grabbed ps using ps -ef |grep someuser | grep someapp and
threw it into an array.

I am going through the array using foreach and doing something like
this (note: format lines up properly in the script, looks kind of odd
in this web-based editor):

sub some_routine() {

format PROC1_OUT =
@<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<
"Tag 1:" $entry                                              $cps
.

format PROC2_OUT =
@<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<
"Tag 2:"   $entry                                              $cps
.

  foreach $entry (@running_procs) {
    print "entered foreach\n" if ($DEBUG);
    $entry =~ s/Element\s\:\s//g;
    # check ps...for $entry.  If running, print up, else print down.
    $cps = false;
    $cps = check_ps($entry);
    write PROC1_OUT;
  }

  foreach $entry (@running_procs2) {
    $entry =~ s/Element\s\:\s//g;
    $entry =~ s/\s*Manager*//g;
    $cps = false;
    $cps = check_ps($entry);
    # check ps...for $entry.  If running, print up, else print down.
    write PROC2_OUT;
  }
}

Here's the deal...I need this to write to STDOUT for both, but need a
separate tag for each format.  This works w/ STDOUT just fine (if I
format STDOUT once), but I don't want the same tag (see format above)
for both outputs.

My question is... is there a way to re-direct a filehandle to STDOUT?
IE... setup the format for the filehandle as above, but then re-direct
the filehandle to STDOUT instead of XYZ filehandle name.  IE
SOMEFILEHANDLE = <STDOUT> so when I print SOMEFILEHANDLE "blah blah
\n"; it prints to STDOUT.

:o)

Thanks in advance for any advice that can be provided.  Thinking there
might be a way to tie the filehandle to STDOUT before the format, but
offhand can't think of a way to do this.  I tried using format STDOUT
= twice, but that didn't produce desired results (makes sense since I
believe format happens before the code is "compiled").

-Pavman42


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


Reply via email to