in reply to Support for hash comments on a line
A regex in any form (split, s/// or m//) is overkill for this task. (Assuming of course that # can't appear in the real data)while (<DATA>) { if ( ( my $p = index( $_, "#" ) ) > -1 ) { substr( $_, $p, -1, "" +) } next if /^\s*$/; print; } __DATA__ #comment this is test#comment #comment this is test #comment this is test #comment this is test #comment
Yves / DeMerphq
--
Have you registered your Name Space?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Support for hash comments on a line (Why use a regex at all?)
by Fastolfe (Vicar) on Nov 04, 2001 at 03:30 UTC |