[Phoenix-pm] Newbie Code
Jonathan K. Smith
jksmith at lexsolutio.com
Fri Sep 16 11:31:17 PDT 2005
I thought I was saving some time using tie instead of reading each line?
And while I'm thinking this might be a really dumb question, do you mean
embbed while loops? Wouldn't that make for a very long embedded while
condition? I'm thinking you mean something else entirely, but I'm just
can't figure out what you meant. I'm completely open to trying it your
way, I just don't see what you mean by the structure of it.
Jonathan Smith
Encore Lex Solutio
www.lexsolutio.com
1-888-389-1658
-----Original Message-----
From: Scott Walters [mailto:scott at illogics.org]
Sent: Friday, September 16, 2005 11:28 AM
To: Jonathan K. Smith
Subject: Re: Newbie Code
Hi Johnathan,
If you mail the list, lurkers might benefit from the Q&A, and other
people might have other helpful comments.
You really, really should read the file line-by-line twice, using just
two while() loops, then call other routines with those lines and split
apart arrays. You'll have two while loops instead of a dozen for loops.
Trust me on this one.
-scott
On 0, "Jonathan K. Smith" <jksmith at lexsolutio.com> wrote:
>
> # Here is a portion of the newer code that I'm doing...
> # So at the start of my script I'll do this....
>
>
>
> tie(my @input_file_lines, "Tie::File", $input_file, mode => 0)
> or die "Can't tie $input_file: $!";
>
>
>
> # Then I am still taking three slices from beginning, middle and
end
> # The @chunk_nums define the starting and ending line of
> # each slice I'm going to take out of the file to view
>
>
>
> my @chunk_nums = ($beg_start_line, $beg_end_line,
> $mid_start_line, $mid_end_line,
> $last_start_line, $last_end_line);
> for my $ctr (0..2) {
> # I am multiplying the $ctr by 2 to get the even number or
> # in turn the first of each two element pair
> for my $line_num ($chunk_nums[2*$ctr]..$chunk_nums[2*$ctr + 1])
{
> push @return _lines, $input_file_lines[$number];
> }
> }
> return @return_lines;
>
>
>
> What I'm wondering while I ponder this, isn't there a method to
> accomplish this without embedding for loops?
>
> Oh and BTW am I supposed to send mail directly to you or to the
list?
>
>
>
> Jonathan Smith
>
> Encore Lex Solutio
>
> [1]www.lexsolutio.com
>
> 1-888-389-1658
>
>
> _________________________________________________________________
>
> From: Jonathan K. Smith
> Sent: Wednesday, September 14, 2005 5:46 PM
> To: 'phoenix-pm at pm.org'
> Subject: Newbie Code
>
> Well here's something that I've been working on, for entirely too
> long. It is supposed format some sampling of another text file to
> easily spot problems. The sections that don't work at all are the
one
> with ############ comments above them, #This is just standard
> notation. For those who actually dig through this, drop me a line
if
> you have any questions.
>
>
>
> Jonathan Smith
>
> Encore Lex Solutio
>
> [2]www.lexsolutio.com
>
> 1-888-389-1658
>
> References
>
> 1. http://www.lexsolutio.com/
> 2. http://www.lexsolutio.com/
More information about the Phoenix-pm
mailing list