Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: whitespaces replace with tabs - help needed...

by bm (Hermit)
on Aug 14, 2003 at 15:23 UTC ( #283908=note: print w/replies, xml ) Need Help??

in reply to whitespaces replace with tabs - help needed...

Why re-invent the wheel?
use Text::Tabs; my $tabstop = 4; @lines_with_tabs = unexpand(@lines_without_tabs);
This module is part of (my) core Perl.

Replies are listed 'Best First'.
Re: Re: whitespaces replace with tabs - help needed...
by thelenm (Vicar) on Aug 14, 2003 at 18:12 UTC

    Of course, this doesn't actually substitute each space character with a tab, as the original poster claims to want (whether that's what s/he really wants is an open question :)...

    Also, the my declaration creates a new lexical variable called $tabstop, which doesn't have any effect on the module's behavior. Instead, you can just get rid of the my since $Text::Tabs::tabstop is exported by the module.

    -- Mike

    XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
    -- grantm, perldoc XML::Simpler

Re: Re: whitespaces replace with tabs - help needed...
by inelukii (Sexton) on Aug 15, 2003 at 12:38 UTC
    I know we are discussing a Perl solution, but for something like this (and assuming you are using some flavor of linux) you can simply use the existing "expand" utility...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://283908]
[Lady_Aleena]: Well, not much of my code. A few little things people here like. The big things though, the more important to me code, people here seem to loathe.
[atcroft]: Lady_Aleena: My early code was pretty horrible... but somewhere early on I learned not to take criticism of my code personally... which was probably a good thing, considering the kind of code I wrote at the time. :\
[Lady_Aleena]: I am hungry, so I'm going to go make something to eat. I hope you figure it out atcroft. Have a nice night!
[atcroft]: I have one script that I have started re-writing several times over the years, and have yet to get it working in a cleaner/better form. (It is some smelly code-I did not even know about hashes at the time I wrote it.)
[atcroft]: Enjoy, Lady_Aleena!

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-05-27 05:30 GMT
Find Nodes?
    Voting Booth?