in reply to add a line based on maxline length
#!/usr/bin/perl -w use strict; my $line; my $maxline = 0; # make sure you get the length of the first line while($line = <DATA>) { chomp($line); print "$line\n"; $maxline = length($line) if length($line)>$maxline; $maxline -= 1 if $line =~ m/.*\032$/; } #----------------------------------------------- # using the char X to see it print a space based on maxline count # in this case it's 29 #----------------------------------------------- print "X" for (1..$maxline); print "\n"; __DATA__ This is my file it doesn't have a blank line at the end of it based on the maxline count of the file that it read. <P>
A couple of things I did notice though:
1. If you're chomping the line coming in, why are you checking it for \r again? Maybe I'm overlooking something there and if so, I know someone will point it out.
2. Why are you checking the first line of data outside your loop?
3. What is all the ( what appears to be - to me anyway ) extraneous code at the top or is that another part of your program that you didn't post?
Hope that helps!
Some people fall from grace. I prefer a running start...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: add a line based on maxline length
by softworkz (Monk) on Aug 01, 2002 at 15:59 UTC |