0
use strict;
use lib qw(./lib);
use Spreadsheet::WriteExcel;
use Math::Random qw(:all);


    $worksheet->write(0, 0, "Zahl", $format); 
    $worksheet->write(0, 1, "Vorkommt",$bold);

    my @rand_arr = map int,random_normal(10,5,5);

    my ($temp,$count) = ("@rand_arr", 0);   
    ($count = $temp =~ s/($_)//g) and printf "%2d:%s vor.\n", $_,$count for @rand_arr;

    $worksheet->write(1, 0, "$_");
    $worksheet->write(1, 1, "$count");


    $workbook->close();

    print "\n";

if u do that u gonna get a good output in the Terminal, but what iam trying to do is, to get the same output in the Excel and i think my problem is here

$worksheet->write(1, 0, "$_");
$worksheet->write(1, 1, "$count"); 

i dont know how to let excel go alone with the $ROW++..

2
  • my $workbook = Spreadsheet::WriteExcel->new("try.xls"); my $worksheet = $workbook->add_worksheet(); Commented Nov 10, 2013 at 15:09
  • thx for the Nice Style note... do u have any idea how can i do that ? Commented Nov 10, 2013 at 15:45

1 Answer 1

1

I'm not sure what your output to terminal code is doing - it looks very odd.

Perhaps you just want:

for my $row (0..$#rand_arr) {
    $worksheet->write($row+1, 0, $row);
    $worksheet->write($row+1, 1, $rand_arr[$row]);
}
Sign up to request clarification or add additional context in comments.

3 Comments

thats what i was searching for thanks a lot... but i still got one problem. $worksheet->write($row+1, 0, $row); its giving me 1-10 and not what he count befor why ?
look the output from Terminal example : 6:2 3:2 8:2 2:1 4:2 0:1 -> number 6 came 2 times, number 3 came twice...
I can't tell what your code that generates the Terminal output is supposed to be doing, but looking at it, I suspect it doesn't do what you actually want. If you edit your question to describe in English what it is supposed to do, with sample random_normal() input and terminal output, I will change my answer to do that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.