On 04/13/2008 07:00 AM, Alex Samad wrote:
Yes I did (thanks twice), but my question which arose from this was whythis did not workperl -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. 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