Re: Print to several logs

2013-08-28 Thread Michael Brader
There are some good answers here so far, but I'd like to recommend a logging module like Log::Log4perl. If your script is more than a run-once throwaway, proper logging will almost certainly be of benefit. Metacpan: https://metacpan.org/module/Log::Log4perl FAQ:

Re: Print to several logs

2013-08-28 Thread Harry Putnam
Rob Dixon rob.di...@gmx.com writes: On 27/08/2013 23:06, John W. Krahn wrote: Harry Putnam wrote: [...] (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log'; open(LOG,$tmplog)or die Can't open $tmplog : $!;

Re: Print to several logs

2013-08-28 Thread Shawn H Corey
On Wed, 28 Aug 2013 10:42:30 -0400 Harry Putnam rea...@newsguy.com wrote: Thanks to all other posters.. lots of good input. It seems to me that recording the same information is many places is a design flaw. If you have the same information in two or more places, it will get out of sync. Write

Re: Print to several logs

2013-08-28 Thread Harry Putnam
Shawn H Corey shawnhco...@gmail.com writes: On Wed, 28 Aug 2013 10:42:30 -0400 Harry Putnam rea...@newsguy.com wrote: Thanks to all other posters.. lots of good input. It seems to me that recording the same information is many places is a design flaw. If you have the same information in

Re: Print to several logs

2013-08-28 Thread Shawn H Corey
On Wed, 28 Aug 2013 12:34:40 -0400 Harry Putnam rea...@newsguy.com wrote: That sounds quite a bit like what cron could do with this hmm. Or use a hard link to preserve the file. -- Don't stop where the ink does. Shawn -- To unsubscribe, e-mail:

Re: Print to several logs

2013-08-28 Thread John W. Krahn
Rob Dixon wrote: On 27/08/2013 23:06, John W. Krahn wrote: my %logs = ( 'one.log' = undef, 'two.log' = undef, ); for my $name ( keys %logs ) { open my $FH, '', $name or die Cannot open '$name' because: $!; $logs{ $name } = $FH; } for my $log_FH ( values %logs ) { print $log_FH kdkdkdkd

Re: Print to several logs

2013-08-28 Thread Rob Dixon
On 28/08/2013 19:06, John W. Krahn wrote: Rob Dixon wrote: use strict; use warnings; use autodie; my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log'; my %logs = map { open my $FH, '', $_; What if open fails?! I have `use autodie`. Rob -- To unsubscribe, e-mail:

Re: Print to several logs

2013-08-28 Thread Shawn H Corey
On Wed, 28 Aug 2013 12:34:40 -0400 Harry Putnam rea...@newsguy.com wrote: Good thinking thanks. It might not really apply here though. I'm no kind of data manager... just a homeboy hillbilly. What I had in mind is writing to a single log file that is dated on the file name for each run of

Print to several logs

2013-08-27 Thread Harry Putnam
I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log'; open(LOG,$tmplog)or die Can't

Re: Print to several logs

2013-08-27 Thread John W. Krahn
Harry Putnam wrote: I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log';

Re: Print to several logs

2013-08-27 Thread Nathan Hilterbrand
See reply below, please I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log';

Re: Print to several logs

2013-08-27 Thread Jim Gibson
On Aug 27, 2013, at 2:14 PM, Harry Putnam wrote: I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (snipped) Check out the IO::Tee module from CPAN. I have not used it, but it is mentioned in several

Re: Print to several logs

2013-08-27 Thread Rob Dixon
On 27/08/2013 23:06, John W. Krahn wrote: Harry Putnam wrote: I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog =

Re: Print to several logs

2013-08-27 Thread Nathan Hilterbrand
Jim, *much* better. I did a search for something like that before I wrote what I did, but I guess I didn't get the search terms right, because I didn't find it. Very cool Nathan On Aug 27, 2013, at 2:14 PM, Harry Putnam wrote: I happen to be scripting something that needs to have two