Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

getting error while writing to a table

by learner@perl (Novice)
on Jul 03, 2013 at 08:38 UTC ( #1042179=perlquestion: print w/ replies, xml ) Need Help??
learner@perl has asked for the wisdom of the Perl Monks concerning the following question:

Hi Masters,

forming records as below

my %input; $input{$EMPNO}[0]="DOB,Name,Empid,salary,Gross_salary,Department,Compa +ny"; $input{$EMPNO}[1]="Month,NET_Salary";

The code which is used to put the records in table and i am reading each field and placing in table

{ my @data; my $table; foreach my $k (keys %input) { foreach (@{$input{$k}}) { chomp(); push( @{@data[$.]},( split /[,\n]/, $_)); } } $table .= "<table border=1>"; for my $i ( 0 .. $#data ) { $table .= "<tr>"; for ( @{@data[$i]}){ $table .= "<td>$_</td>\r\n"; } $table .= "</tr>"; } $table .= "</table>"; }

The output i want in a tabular format, when i run the above code i have error,Can't use an undefined value as an ARRAY reference

I want to display the data in tabular format, as i am not much familiar with the array refernce, any solution for this, i already posted this on monk and used the same code but getting error

DOB,Name,Empid,salary,Gross_salary,Department,Company Month,NET_Salary

Comment on getting error while writing to a table
Select or Download Code
Re: getting error while writing to a table
by Anonymous Monk on Jul 03, 2013 at 08:46 UTC
      Hi,

      here it is the output of dumper

      $VAR1 = '12'; $VAR2 = [ '01-01-1989,ABC,12,12000,300000,Finanance,BC' 'January,60000' ]; $VAR3 = '13'; $VAR4 = [ '01-01-1988,BCH,13,15000,400000,Manfacturing,CB' 'Feburary,400000' ];

      where i am missing, did i used wring code while printing data to table

        Try again please, dd\%foo the \ is important
Re: getting error while writing to a table
by 2teez (Priest) on Jul 03, 2013 at 10:18 UTC

    Hi learner@perl,
    Honestly, am really sure there are several monks that would want to help, but since one can't really understand what you want, how could one.
    Please, could you check How do I post a question effectively?, follow the instruction and let's make ourselves happy... :)

    Update:
    ..I want to display the data in tabular format,
    There are several options, you can use printf function, you could use Text::Table and several other CPAN modules

    ..as i am not much familiar with the array refernce..
    perldsc could be of help. Check it out.

    ..i already posted this on monk and used the same code but getting error...
    You are still on perlmonks... :)

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me

      There is a cross post on the Perl Gurus forum.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1042179]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (19)
As of 2014-10-30 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls