Skumar2015 has asked for the wisdom of the Perl Monks concerning the following question:

#!/usr/local/bin/perl use strict; use warnings; my $filename = 'C:Desktop\data.log'; open(my $file1, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; while (my $row = <$file1>) { chomp $row; print "$row\n"; }
when i run this file i will get some '12345'as an output. Now I need to copy the log file output into existing excel sheet day by day. please help me.
  • Comment on when i run a log file,will get some output in numbers say'12345' ,i would like to copy it in excel file?
  • Download Code

Replies are listed 'Best First'.
Re: when i run a log file,will get some output in numbers say'12345' ,i would like to copy it in excel file?
by ww (Archbishop) on Jul 31, 2015 at 22:33 UTC

    Does the $row ('12345' ??) you're printing contain the data you're trying to capture? If not, we'll need a lot more info about what your $row contains.

    If so, check out threads here on spreadsheets. There are many re Excel. And if what you find isn't adequate, then perhaps you need to take a step back and learn about opening files; writing to them; closing them, etc.

    You'll do yourself a lot of good by using your own efforts trying to find a way to do this. I suggest starting with Super Search and a search term like 'spreadsheet' or 'Excel.'

Re: when i run a log file,will get some output in numbers say'12345' ,i would like to copy it in excel file?
by locked_user sundialsvc4 (Abbot) on Jul 31, 2015 at 23:33 UTC

    Please edit your post to use <code> tags to enclose the Perl source code.

    Now, when it actually comes down to “getting it into a spreadsheet,” you basically have two choices.   One strategy is to build an .XSLX file.   Excel::Writer::XSLX purports to do that.   (Spreadsheet::WriteExcel and Spreadsheet::WriteExcelXML are others.)   However, personally, I don’t do it that way.   Instead, I use OLE.

    Querylet::Output::Excel::OLE is a good example (see the Source hyperlink on the page ...) of how this sort of thing can be done.   (Win32::OLE and Win32::OLE::Const do the actual heavy-lifting.)   I open an Excel.Spreadsheet OLE-object and tell it (Excel, itself) what I want to do.   Excel is the one that does the actual work.