in reply to regex basics

I suggest this:

#!/usr/bin/perl while(<>) { next if /;{2,}/; next if /;\s{1}/; print unless /^\n/; } __END__ strip_ini.pl php.ini [PHP] ;user_ini.filename = ".user.ini" ;user_ini.filename = ;user_ini.cache_ttl = 300 engine = On short_open_tag = Off asp_tags = Off precision = 14 y2k_compliance = On output_buffering = 4096 ;output_handler = zlib.output_compression = Off ;zlib.output_compression_level = -1 ...about 300 lines more

Usage: strip_ini.pl php.ini > php.stripped.ini

Note:

;;;;;;;;;;;;;;;;;;; <-- the first next skips the ASCI art ; About php.ini ; <-- the second next skips the explanations ;;;;;;;;;;;;;;;;;;;
The print unless /^\n/ prevents unwanted printing of emtpy lines. I don't know for the moment why they are there...

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Replies are listed 'Best First'.
Re^2: regex basics
by Anonymous Monk on Feb 04, 2015 at 07:44 UTC
    I think you're correct - the ascii art lines (;;;) SHOULD evaluate to TRUE using ($_ !~ /;\s+/). But the art is NOT present in the output (with the latest posted code)