For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > September 2006 > looping through complicated hashes..









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author looping through complicated hashes..
Michael Alipio

2006-09-08, 3:57 am

Hi,

I have an input file with 7 columns each line. Words
are separated with 1 or more spaces..
Now, I want each of these lines placed into
HTML::Table's rows.

The HTML::Table has something like this.
each row (with 7 cells) is encolsed with []. I want
each row, populated with each line in my input file.

my $table = new HTML::Table(-data=> [['1stRowValue1',
'1stRowValue2', upto '1stRowValue7'], ['2ndRowValue1',
'2ndRowValue2', upto '2ndRowValue7']]

So far, all I can do is open the input file, read it
line by line, split each line and store it in an
array.

However, I'm not sure how to insert my loop inside
HTML::Table declaration section..
Any idea?

Thanks!


________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Michael Alipio

2006-09-08, 3:57 am

ignore this one.. I've already figured out how.
thanks.

--- Michael Alipio <daem0nb0y@yahoo.com> wrote:

> Hi,
>
> I have an input file with 7 columns each line. Words
> are separated with 1 or more spaces..
> Now, I want each of these lines placed into
> HTML::Table's rows.
>
> The HTML::Table has something like this.
> each row (with 7 cells) is encolsed with []. I want
> each row, populated with each line in my input file.
>
> my $table = new HTML::Table(-data=>
> [['1stRowValue1',
> '1stRowValue2', upto '1stRowValue7'],
> ['2ndRowValue1',
> '2ndRowValue2', upto '2ndRowValue7']]
>
> So far, all I can do is open the input file, read it
> line by line, split each line and store it in an
> array.
>
> However, I'm not sure how to insert my loop inside
> HTML::Table declaration section..
> Any idea?
>
> Thanks!
>
>
> ________________________________________
__________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam
> protection around
> http://mail.yahoo.com
>
> --
> To unsubscribe, e-mail:
> beginners-unsubscribe@perl.org
> For additional commands, e-mail:
> beginners-help@perl.org
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
>
>
>



________________________________________
__________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Ashok Varma

2006-09-08, 3:57 am

Hi Michael,

Following is one way ...
Here is am assuming that you have dumped that data into a array named
'@your_array' which contains each line in array references(array of arrays).
--------------------------------------------------------------------------------------------
$table = new HTML::Table;
foreach my $line (@your_array) {
$table->addRow(@$line);
}
--------------------------------------------------------------------------------------------
Hope this helps.

Ashok

On 9/8/06, Michael Alipio <daem0nb0y@yahoo.com> wrote:
>
> Hi,
>

I have an input file with 7 columns each line. Words
> are separated with 1 or more spaces..
> Now, I want each of these lines placed into
> HTML::Table's rows.
>
> The HTML::Table has something like this.
> each row (with 7 cells) is encolsed with []. I want
> each row, populated with each line in my input file.
>
> my $table = new HTML::Table(-data=> [['1stRowValue1',
> '1stRowValue2', upto '1stRowValue7'], ['2ndRowValue1',
> '2ndRowValue2', upto '2ndRowValue7']]
>
> So far, all I can do is open the input file, read it
> line by line, split each line and store it in an
> array.
>
> However, I'm not sure how to insert my loop inside
> HTML::Table declaration section..
> Any idea?
>
> Thanks!
>
>
> ________________________________________
__________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


Charles K. Clarkson

2006-09-09, 3:57 am

Michael Alipio wrote:

: ignore this one.. I've already figured out how.

Why not post your solution for the archives? Someone
else may run across your question during a search and
will not know the answer you found.

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer

254 968-8328

Don't tread on my bandwidth. Trim your posts.

Jack Faley

2006-09-09, 3:57 am

On 9/8/06, Charles K. Clarkson <cclarkson@htcomp.net> wrote:
>
> Michael Alipio wrote:
>
> : ignore this one.. I've already figured out how.
>
> Why not post your solution for the archives? Someone
> else may run across your question during a search and
> will not know the answer you found.
>
> HTH,
>
> Charles K. Clarkson
> --
> Mobile Homes Specialist
> Free Market Advocate
> Web Programmer
>
> 254 968-8328
>
> Don't tread on my bandwidth. Trim your posts.
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>




I was about to reply with the same thing.........

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com