imnotverygood has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I have created a small program to break up each different part of a syslog file, using regex and then rearranging them and then writing them to an output file. Example syslog line: Note, I know this isn't code.
Jan 4 12:05:21 ubuntu NetworkManager[1034]: <info> (eth0): now unmanagedI have broken it down into
keyword = NetworkManager, host = ubuntu, datetime = Jan 4 12:05:21, info = <info> (eth0): now unmanaged, portno = NetworkManager[1034]
To write it to the file I have used this code
However, when I open the file (output-input.txt). The port number is placed on a new line, even though I haven't asked it to. This only happens with the port number. This mucks up my next task as I want to bubble sort each line to put it in alphabetical order. I can't see a problem with my code. I need help, thanksprint OUTPUTINTER "**". $keyword. "**". " ". $host. " ". $datetime. " + ". $info. " ". $portno. "\n"; #The line above prints the following to the file output-inter.txt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Writing to a file is not being formatted correctly.
by choroba (Cardinal) on Dec 16, 2015 at 14:07 UTC | |
|
Re: Writing to a file is not being formatted correctly.
by Laurent_R (Canon) on Dec 16, 2015 at 23:04 UTC |