Have the data in an array and do
i = 0;
foreach (@text) {  $text2[i++] = $_ if (! m/^\s$/);  }

On 3/12/07, Rob Dixon <[EMAIL PROTECTED]> wrote:
Grant wrote:
>> > I'm having a lot of trouble figuring out how to remove blank lines
>> > from my HTML.  The lines are generated by my shopping cart.  I use
>> > (and highly recommend) interchange:
>> >
>> > http://www.icdevgroup.org
>> >
>> > I basically want to wrap all of my code in [filter
>> > no_blank_lines][/filter].  no_blank_lines is defined this way:
>> >
>> > CodeDef no_blank_lines Routine <<EOR
>> > sub {
>> > my $val = shift;
>> > #$val =~ s/\s+//g;
>> > #$val =~ s/\s*\n+\s*/\n/g;
>> > #$val =~ s/[^\S\n]*\n\s*\n/\n/g;
>> > $val =~ s/\n\n+/\n/g;
>> > return $val;
>> > }
>> > EOR
>> >
>> > Those are all regexp's I've tried.  They all seem to do nothing except
>> > the first one removes all whitespace including the spaces in between
>> > characters in my code which obviously breaks everything.  Can anyone
>> > suggest a solution?
>>
>>   $val =~ s/^\s*\n//mg;
>
> I'm not having any luck there either.  I'm not sure what is actually
> creating the blank lines.  It could be spaces, tabs, or some other
> blank line creator.

The \s marker will match all of those. Can you show us your code please?
Don't forget that your function is returning the modified text and you have
to assign it to something - it won't change the contents of the string you
pass as a parameter written that way.

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to