in reply to How to read data from csv file and place the data on HTML format

You are getting the ARRAY(0x....) output because you are asking Perl to stringify array references with this code:

push(@report, [$csv->fields]); # Later... return ( join( "\n", @report ) );

The [ ] brackets create an anonymous ARRAY ref and stick the contents of $csv->fields inside. Hence @report contains a bunch of references, and when you try to join them, you just get a bunch of ARRAY(0x...) strings.

Using ARRAY refs in @report was probably the right idea, so now you just need to do a little extra work to dereference each element and join them together. Here's a quick runnable example illustrating the idea:

my @refs = ([qw/foo bar baz/], [qw/fee fie foe/], [qw/red green/]) +; print join "\n", map { join ',', @$_ } @refs;

Instead of printing the result of join, you can of course assign it to a scalar.

Replies are listed 'Best First'.
Re^2: How to read data from csv file and place the data on HTML format
by Perlseeker_1 (Acolyte) on Jun 27, 2013 at 08:24 UTC
    Hi Monks,

    I used the above recommended one, i can see the output on

    email body but it was not in order

    i want the data to be displayed in order

    Any help on this please

      Hi Monks,
      Title_1,Title_2,Title_3,Title_4,Title_5,Title_6,Title_7,Title_8,Title_ +9,Title_10 Apr13,Gkel_gz.dat.gz,1456,1456,Check_ABC_TT1_INTL.dat,489,Gkel_gz.dat, +124,422,TRUE ' ',' ',' ',' ',Check_AB_TT1.dat,124 May13,Gkel_gz.dat.gz,6541',6541,Check_ABC_TT1.dat,466,Check_AB_TT1_TT2 +.dat,07364,07364,TRUE ' ',' ',' ',' ',Check_AB_TT1.dat,263 Jun13,Gkel_gz.dat.gz,62382,62382,Check_ABC_TT1.dat,470,Check_AB_TT1_TT +2.dat,04220,04220,TRUE ' ',' ',' ',' ',Check_AB_TT1.dat
      print DETAIL "$pattern,$Orig_gz[0],$Orig_gz[1],$Orig_gz[1],$INTL[0]->[ +0],$INTL[0]->[1],$Orig[0],$Orig[1],$Orig[1],TRUE\n"; print DETAIL "'\t','\t','\t','\t',$INTL[1]->[0],$INTL[1]->[1]\n"; return join "\n", map { join ',', @$_ } @report; my $body = ConvertData();

      How can i put the data in tabular form, any suggestions

      In output i am seeing ',', how can i remove that

      As i am new to this, any inputs please

        The short answer is to stop printing things you don't want to print. It should be fairly obvious where the ',' occurs within the code you've posted.

        The long answer is to stop, take a step back and learn the basics. Copying and pasting code people have given you which you don't understand and piecing together a program in this manner isn't wise. If you don't understand what it code you've been given does make some effort to find out how and why it does what it's doing. If you need more help ask specific questions.