[Cialug] Perl - find blank/white line

Josh More cialug@cialug.org
Tue, 12 Apr 2005 10:06:16 -0500


--=__Part6A497EF8.0__=
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

I would just use: 
 
if ($line =~ /^\s+$/) 
 
This would match all lines that start (^) and end ($) with whitespace
(\s) and have nothing else there (+) 
 
-Josh More 
 


>>>cniesen@gmx.net 04/12/05 9:55 am >>>
Hello Perl gurus

I'm having a program that reads lines and I want to find the first line
without a printable character and I am having problems creating the
correct condition.  So far I have:

  if ($line le )

But that treats a line starting with a tab as a blank line (aka the if
is true) but unless the tab is not followed by a printable character I
would like to tread it as a blank line.

If it helps, the lowest ord. of a printable character is 33 (!).

String functions prefered but regex is also accepted if need be.  Any
help is appreciated.
  Claus

Cialug mailing list
Cialug@cialug.org
http://cialug.org/mailman/listinfo/cialug


--=__Part6A497EF8.0__=
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Description: HTML

<html>
  <head>
    <style type=3D"text/css">
      <!--
        body { margin-bottom: 1px; font-variant: normal; margin-left: 4px; =
line-height: normal; margin-right: 4px; margin-top: 4px }
      -->
    </style>
   =20
  </head>
  <body style=3D"margin-bottom: 1px; margin-left: 4px; margin-right: 4px; =
margin-top: 4px">
    <DIV>      I would just use:
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>if &#40;&#36;line &#61;&#126;&nbsp;/&#94;&#92;s&#43;&#36;/&#41;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>This would match all lines that start &#40;&#94;&#41; and end =
&#40;&#36;&#41; with whitespace &#40;&#92;s&#41; and have nothing else =
there &#40;&#43;&#41;
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV>-Josh More
    </DIV>
    <DIV>&nbsp;</DIV>
    <DIV><br><br>&gt;&gt;&gt;cniesen@gmx.net 04/12/05 9:55 am &gt;&gt;&gt;<=
br>Hello Perl gurus<br><br>I&#39;m having a program that reads lines and I =
want to find the first line<br>without a printable character and I am =
having problems creating the<br>correct condition.&#160;&nbsp;So far I =
have:<br><br>&#160;&#160;if &#40;&#36;line le &quot; &quot;&#41;<br><br>But=
 that treats a line starting with a tab as a blank line &#40;aka the =
if<br>is true&#41; but unless the tab is not followed by a printable =
character I<br>would like to tread it as a blank line.<br><br>If it =
helps&#44; the lowest ord. of a printable character is 33 &#40;&#33;&#41;.<=
br><br>String functions prefered but regex is also accepted if need =
be.&#160;&nbsp;Any<br>help is appreciated.<br>&#160;&#160;Claus<br><br>Cial=
ug mailing list<br>Cialug@cialug.org<br>http://cialug.org/mailman/listinfo/=
cialug<br>    </DIV>

  </body>
</html>

--=__Part6A497EF8.0__=--