"slash" <satishigwu.edu> wrote in message
news:30fe9f1e.0308081032.a1b045fposting.google.co m...
> Hi,
> I have been struggling with this for a while and could certainly use
> some help.
> I am using the Text::Table module for performing ngrams and trying to
> add the corresponding filename information to whatever file that's
> being processed. In other words, given a file.txt, i do my ngrams and
> select to output specific columns. At the end of each line, I want to
> add the text file name. Can someone please help me with how I should
> go about this.
I suspect that the reason why your posting has not elicited a response is
that to adequately diagnose your problem one would have to install two
non-standard modules, Text::Table and Text::Aligner (on which Text::Table
depends), and readers of this list are not likely to install modules just to
respond to postings. You might do somewhat better on
comp.lang.perl.modules -- and have you looked at Text::Ngram?

But since you asked for any suggestions on your code ...
(1) Have you tried running your script with 'use warnings; use strict;'?
Your understanding of use of 'my' to scope variables appears confused.
> foreach $word ( words ) { # not scoped with 'my'
[snip]
> my lines = $tb->add("$stack[-4]", "$stack[-3]", "$stack[-2]",
> "$stack[-1]", "*");
> my lines = $tb->add("$stack[-3]", "$stack[-2]", "$stack[-1]",
> "-1", "-1");
> my lines = $tb->table($line_number, $n);
[above would generate a warning]

(2) What's your rationale for slurping all the data in at once (undef $/) as
opposed to line-by-line processing? Such modification of $/ should be
scoped to the smallest possible block.
> undef $/;
> my words = split /\W+/, <> ;
Jim Keenan