Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Simple way to skip spaces and # comments

by perlfan (Vicar)
on Jul 31, 2020 at 11:28 UTC ( #11120121=note: print w/replies, xml ) Need Help??

in reply to Simple way to skip spaces and # comments

I usually just s/// that kind of thing,
my $line = 'valid text blah blah # delete me and everything after poun +d # also this'; $line =~ s/#.*$//; print qq{"$line"\n};
results in:
"valid text blah blah "
I don't have an answer for your #2 question at the end.

Replies are listed 'Best First'.
Re^2: Simple way to skip spaces and # comments
by leszekdubiel (Scribe) on Jul 31, 2020 at 13:56 UTC

    To be more precise... $a is a reference to string, that is beeing parsed. pos $$a shows current parsing position. From that position I need to skip all spaces and comments that extend maybe on many lines in that string. Positve zero-length match should be avoided.

      >Questions: (1) what is the better solution to strip white chars

      Asked and answered. \_(ツ)_/

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11120121]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2020-10-29 05:51 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (269 votes). Check out past polls.