in reply to new file per line output
You've received excellent scripting suggestions. Still, perhaps the following minor modifications of your script will be helpful:
use strict; use warnings; use DateTime; use POSIX qw(strftime); use autodie; open my $logFH, '<', 'second.txt'; while (<$logFH>) { my ( $streamname, $streamid, $timedate ) = split /[@\s]/; my $time_t = POSIX::strftime( "%Y-%m-%d %r", localtime($timedate) +); open my $fh, '>', "$streamid/$streamname"; print $fh <<END; <event> <stream-id>$streamid</stream-id> <event-name>$streamname</event-name> <primary-event> <delete-time>$time_t</delete-time> </primary-event> </event> END }
Edit: Added use autodie; to catch any silent close failures. Thank you, davido.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: new file per line output
by davido (Cardinal) on Dec 31, 2013 at 19:16 UTC | |
by Kenosis (Priest) on Dec 31, 2013 at 19:22 UTC | |
|
Re^2: new file per line output
by AnomalousMonk (Archbishop) on Dec 31, 2013 at 20:43 UTC | |
by Kenosis (Priest) on Dec 31, 2013 at 21:46 UTC | |
|
Re^2: new file per line output
by karlgoethebier (Abbot) on Jan 01, 2014 at 14:22 UTC | |
by Kenosis (Priest) on Jan 01, 2014 at 18:28 UTC |