Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Creating table through PERL

by 2teez (Priest)
on Apr 23, 2013 at 15:46 UTC ( #1030176=note: print w/ replies, xml ) Need Help??


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.

#!/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
Output: First Table is by Perl6::Form and the Second Table by Text::Table
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
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.
Infact, you can even write your data to an Excel file directly if you wish using module like Spreadsheet::WriteExcel and the likes.
That been said, it's important to say, there is nothing like PERL as Perl is not an acronym see What's the difference between "perl" and "Perl"?
Hope this helps.

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


Comment on Re: Creating table through PERL
Select or Download Code
Re^2: Creating table through PERL
by sid.verycool (Novice) on Apr 24, 2013 at 05:58 UTC
    Practical Extraction and Reporting Language http://en.wikipedia.org/wiki/Perl and thanks for correcting me 2teez, I missed that this is "NON OFFICIAL"

      Please, also check this History->Names and note this line "..There is some contention about the all-caps spelling "PERL", which the documentation declares incorrect and which some core community members consider a sign of outsiders.."
      You are welcome sid.verycool.

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030176]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-08-22 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (155 votes), past polls