I haven't done much with real parsing beyond simple regexen, but I believe what you really want to do is break the line into tokens:
my $to_parse = q(my $thisRocks = " That's what I said!";); my @tokens = get_tokens($to_parse); # The elements in @tokens will look something like: # # 0: my # 1: $thisRocks # 2: = # 3: " That's what I said!" # 4: ; # # Now you can just print them out print @tokens; __OUTPUT__ my$thisRocks=" That's what I said!";
Of course, I'm leaving out the implementation of get_tokens() (as you can see above, it would take in a string to parse and returns a list with each token in a single element). This is the part that goes beyond my experiance, so I'm leaving implementation of that alone. Hopefully, this will be enough for you to dig up the rest of the information. I do know that relevent code for how perl breaks it up is the the perl source code in toke.c.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
In reply to Re: Remove Tabs and white space from a line except in Quotes
by hardburn
in thread Remove Tabs and white space from a line except in Quotes
by SmokeyB
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |