in reply to Creating table through PERL
Hi sid.vertcool,
If I may add a few point here.
~ I need to create a table..how do i start my work
There are several ways you can do this. You can use Text::Table as mentioned by clueless newbie, one can also use Perl6::Form, infact, you can use printf.
See below for some example, using both Perl6::Form and Text::Table.
Output: First Table is by Perl6::Form and the Second Table by Text::Table#!/usr/bin/perl use warnings; use strict; use Perl6::Form; my $student_data; chomp( my $title = <DATA> ); push @{$student_data}, [split] while <DATA>; print "\n\nFIRST TABLE:\n"; print form "==============================================", "| STD_NAME | STD_NUM | SUB_A | SUB_B | SUB_C |", "=============================================="; print form "| {<<<<<<} |{||||||} | {||||}|{|||||}|{|||||}|", $_->[0], $_->[1], $_->[2], $_->[3], $_->[4] for @$student_data; use Text::Table; print "\n\nSECOND TABLE:\n"; my $plain_table = Text::Table->new( split /\s+/, $title ); $plain_table->load( [@$_] ) for @$student_data; print $plain_table; __DATA__ student_name student_number subject_A subject_B subject_C zadok 3006 45 67 -- mechi 2917 67 89 45 judas 3010 20 -- 12 temin 1122 60 56 90
NOTE: Please, note that I don't know how the OP is getting his/her data as shown in the Original Post, I only used what I can come up with for data here.FIRST TABLE: ============================================== | STD_NAME | STD_NUM | SUB_A | SUB_B | SUB_C | ============================================== | zadok | 3006 | 45 | 67 | -- | | mechi | 2917 | 67 | 89 | 45 | | judas | 3010 | 20 | -- | 12 | | temin | 1122 | 60 | 56 | 90 | SECOND TABLE: student_name student_number subject_A subject_B subject_C zadok 3006 45 67 -- mechi 2917 67 89 45 judas 3010 20 -- 12 temin 1122 60 56 90
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating table through PERL
by sid.verycool (Novice) on Apr 24, 2013 at 05:58 UTC | |
by 2teez (Vicar) on Apr 24, 2013 at 06:22 UTC |