Re: Redirecting file handler to STDOUT (SOLVED)

2007-06-22 Thread Ben Edwards

Cool, the * is by reference.

Thanks,
Ben

On 22/06/07, Paul Lalli [EMAIL PROTECTED] wrote:

On Jun 22, 5:57 am, [EMAIL PROTECTED] (Ben Edwards) wrote:
 I am opening a log file:

 open( LOGFILE,  cronlog.txt );

 This is being written to in lots of places.

 I have been asked to change the program so if -m (manual) flag is
 passed the stuff that goes to the log file is send to standard out
 instead.  Is it possible to change the above command to redirect
 LOGFILE to STDOUT (i.e. make the two the same thing.

 i.e.

 if ( defined( $opt_m ) ) {
   open( LOGFILE, STDOUT );} else {

   open( LOGFILE,  cronlog.txt );

 }

 I even tried:

 LOGFILE = STDOUT;

 But I get:

 Bareword STDOUT not allowed while strict subs in use

 Whjenever I try to use STDOUT;(

Because this is the equivalent of saying
LOGFILE = STDOUT;
which obviously makes no sense, so by using strict such things are
prevented.

You can however assign the typeglob *LOGFILE to *STDOUT:

if (defined( $opt_m) ) {
   *LOGFILE = *STDOUT;
}

Paul Lalli


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






--
Ben Edwards - Bristol, UK
If you have a problem emailing me use
http://www.gurtlush.org.uk/profiles.php?uid=4
(email address this email is sent from may be defunct)

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




Re: Redirecting file handler to STDOUT (SOLVED)

2007-06-22 Thread Chas Owens

On 6/22/07, Ben Edwards [EMAIL PROTECTED] wrote:

Cool, the * is by reference.

snip

It is a lot more complicated than that.  Typeglobs allow you access to
the symbol table.  You can do some really cool things like

*hw = sub { print Hello, , shift, \n };
hw(bork)

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




Re: Redirecting file handler to STDOUT (SOLVED)

2007-06-22 Thread Paul Lalli
On Jun 22, 1:43 pm, [EMAIL PROTECTED] (Ben Edwards) wrote:
 Cool, the * is by reference.

If you re-read my post, you will see the word reference no where in
it.  This has nothing to do with references.  It involves typeglobs.

By the way, this is now the third time (that I've noticed) that you've
started a new thread to say that your problem has been solved.  It is
conventional to reply to the same thread that has already been
started.  Thank you.

Paul Lalli


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