On Sun, Apr 13, 2008 at 09:21:51AM -0500, Mumia W.. wrote: > On 04/13/2008 07:00 AM, Alex Samad wrote: >> Yes I did (thanks twice), but my question which arose from this was why >> this did not work >> >> perl -nle 'next if ( /^\s*;/); print' sip.conf >> >> why do I need the length statement[?] >> >> perl -nle 'next if ( /^\s*;/); print if length $_ > 0' sip.conf >> >> [...] > > First, this might be easier to understand: > > perl -nle 'print unless /^\s*(#|$)/' sources.list > (Replace "#" with ";".) > > Secondly, the "length" statement was needed for your earlier code > because /^\s*;/ won't match blank lines.
I did not want to remove the blank lines of the file, I had presumed their were not any blank lines in there. upon closer inspection there are So this now all makes sense any now I feel a bit silly Thanks everyone > > Take this code: > perl -nle 'next if ( /^\s*#/); print if length $_ > 0' sources.list > > Simplify it a bit and use more regex's: > perl -nle 'next if (/^\s*#/ or /^\s*$/); print' sources.list > > Integrate the regex'es into a single one: > perl -nle 'next if /^\s*(#|$)/; print' sources.list > > Eliminate "next": > perl -nle 'print unless /^\s*(#|$)/' sources.list > > > HTH > > > > -- > To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a > subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED] > > -- "I like to tell people when the final history is written on Iraq, it will look like just a comma because there is -- my point is, there's a strong will for democracy." - George W. Bush 09/24/2006 in an interview on CNN
signature.asc
Description: Digital signature