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

Re: Cleaning Whitespace from Source Code

by Prior Nacre V (Hermit)
on Dec 09, 2004 at 08:55 UTC ( [id://413455]=note: print w/replies, xml ) Need Help??


in reply to Cleaning Whitespace from Source Code

As already stated above, it is unclear exactly what you trying to achieve.

The following is probably too simplistic as a complete solution but the two methods described may be useful in parts of your final script.

  • $/ is used here to remove duplicate blank lines
  • y/// (alias tr///) is used here to remove duplicate spaces

(These are not their only uses.)

[ ~/tmp ] $ cat spacey_text 1 12 23 32 21 1 a b c d e 1 blank: 2 blanks: 3 blanks: end_blanks [ ~/tmp ] $ perl -we 'use strict; { local $/ = ""; while (<>) { $_ =~ +y/ / /s; print $_; } }' spacey_text 1 12 23 32 21 1 a b c d e 1 blank: 2 blanks: 3 blanks: end_blanks [ ~/tmp ] $

Regards,

PN5

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (6)
As of 2024-05-21 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found