in reply to perl substitution difficulty
prints:#!/usr/bin/perl use strict; use warnings; open (DATA,"</var/log/messages") || die 'Unable to open log file'; open (TMP, ">/tmp/messages.csv") || die 'Unable to write to file'; while (<DATA>) { chomp; my (@cols) = split(/\s+/, $_, 6); print TMP join(',',@cols), "\n"; } close TMP; close DATA; __DATA__ Oct 1 13:23:25 smoothwall-swe3 kernel: Allocating PCI resources start +ing at 10000000 (gap: 08000000:f6c00000) Oct 1 13:23:25 smoothwall-swe3 kernel: Built 1 zonelists Oct 1 13:23:25 smoothwall-swe3 kernel: Kernel command line: BOOT_IMAG +E=SmoothWall ro root=804 ramdisk_size=8192 no-scroll panic=30 Oct 1 13:23:25 smoothwall-swe3 kernel: Enabling fast FPU save and res +tore... done. Oct 1 13:23:25 smoothwall-swe3 smoothd: Loading Plugins for Module "/ +usr/lib/smoothd/sysinstall.so
Oct,1,13:23:25,smoothwall-swe3,kernel:,Allocating PCI resources starti +ng at 10000000 (gap: 08000000:f6c00000) Oct,1,13:23:25,smoothwall-swe3,kernel:,Built 1 zonelists Oct,1,13:23:25,smoothwall-swe3,kernel:,Kernel command line: BOOT_IMAGE +=SmoothWall ro root=804 ramdisk_size=8192 no-scroll panic=30 Oct,1,13:23:25,smoothwall-swe3,kernel:,Enabling fast FPU save and rest +ore... done. Oct,1,13:23:25,smoothwall-swe3,smoothd:,Loading Plugins for Module "/u +sr/lib/smoothd/sysinstall.so
|
|---|